Stackless Python, eventual merge?

Martin v. Loewis martin at v.loewis.de
Thu Sep 19 15:25:21 EDT 2002


Christian Tismer <tismer at tismer.com> writes:

> > Academically, I don't think the results are unpredictable, as
> > micro-thread switch occur at predictable points in processing.
> 
> Yes, right now, but this will change pretty soon.

You mean, tasklet switches will occur at unpredictable times?

This sounds like a bad idea.

> I am not saying that the random module is not thread safe (although
> I'm not sure if it is). 

To quote from the docstring:

  Multi-threading note: the random number generator used here is not
  thread- safe; it is possible that two calls return the same random
  value.

> The point is: Microthread safety is more than thread safety, since
> microthreads don't care about thread locks, since they are still *in
> the same thread*.

The issues are the same: the values of data may change at points where
you don't expect them to change. Thread-safety means to be aware of
such changes, and protect against them, by means of synchronization.

> I have to do rigid locking of every unknown piece of code, until
> somebody explicitly claims some code to be switchable.

This, again, sounds terrible. I doubt it will help, and users will
complain.

Regards,
Martin



More information about the Python-list mailing list