[Python-ideas] A concurrency survey of sorts

Yuval Greenfield ubershmekel at gmail.com
Thu Nov 3 14:10:23 CET 2011


turtle isn't thread safe.

http://bugs.python.org/issue1702036

Also, here's just a random exception:

Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
>>> turtle.forward(10)
>>> import turtle
>>> from threading import Thread
>>> class walker(Thread):
...     def run(self):
...             for i in range(100):
...                     turtle.forward(10)
...                     turtle.left(10)
...
>>> [walker().start() for i in range(5)]
[None, None, None, None, None]
>>> Exception in thread Thread-2:
Traceback (most recent call last):
  File "c:\python32\lib\threading.py", line 736, in _bootstrap_inner
    self.run()
  File "<stdin>", line 4, in run
  File "<string>", line 1, in forward
  File "c:\python32\lib\turtle.py", line 1637, in forward
    self._go(distance)
  File "c:\python32\lib\turtle.py", line 1605, in _go
    self._goto(ende)
  File "c:\python32\lib\turtle.py", line 3159, in _goto
    screen._pointlist(self.currentLineItem),
  File "c:\python32\lib\turtle.py", line 755, in _pointlist
    cl = self.cv.coords(item)
  File "<string>", line 1, in coords
  File "c:\python32\lib\tkinter\__init__.py", line 2162, in coords
    self.tk.call((self._w, 'coords') + args))]
  File "c:\python32\lib\tkinter\__init__.py", line 2160, in <listcomp>
    return [getdouble(x) for x in
ValueError: could not convert string to float: 'itemconfigure'



On Wed, Nov 2, 2011 at 9:36 PM, Mike Meyer <mwm at mired.org> wrote:
> In order to get a better idea of where things stand, I'd like to get
> answers to a few questions. This isn't a traditional broadbased
> survey, but an attempt to get answers from a few people who might know
> or have good ideas. This is probably where I should have started, but
> better late than never.
>
> 1) How much of the Python standard library is known to be thread safe?
>
> 2) How many packages in PyPI are known to be thread safe?
>
> 3) Can you suggest another approach to getting safe high-performance
> shared data in concurrent operation? I've already considered:
>
>  a) I proposed making actions that mutate data require locked objects,
> because I've seen that work in other languages. I recognize that
> doesn't mean it will work in Python, but it's more than I can say
> about the alternatives I knew about then.,
>
>  b) Bertrand Meyer's SCOOPS system, designed for Eiffel. It has two
> major strikes against it: 1) it is based on type attributes on
> *variables*, andI could figure out how to translate that to a language
> where variables aren't typed. 2) I don't know that there's a working
> implementation.
>
> 4) Can you suggest a minor change that would move things toward safer
> concurrent code with high-performance shared data? I can see two
> possibilities:
>
>  a) Audit any parts of the standard library that aren't already known
> to be thread safe, and flag those that aren't.  Fixing them may want
> to wait on a better mechanism than posix locks.
>
>  b) Add a high-level, high-performance shared object facility to the
> multiprocess package.
>
>    Thanks,
>    <mike
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list