Can PySerial's write method be called by multiple threads?
Joel Koltner
zapwireDASHgroups at yahoo.com
Wed Aug 25 15:02:27 EDT 2010
"Thomas Jollans" <thomas at jollybox.de> wrote in message
news:mailman.36.1282762569.29448.python-list at python.org...
> I expect that it gives away the GIL to call the resident write() function,
> to
> allow other threads to run while it's sitting there, blocking. I haven't
> looked at the code, so maybe it doesn't hand over the GIL, but if it
> doesn't,
> I'd consider that a bug rather than a feature: the GIL shouldn't be abused
> as
> some kind of local mutex, and only gets in the way anyway.
Ah, I expect you're correct. I'm still largely a Python newbie, and only know
enough about things like the GIL to get myself into trouble.
> Speaking of the GIL, you shouldn't rely on it being there. Ever. It's a
> necessary evil, or it appears to be necessary. but nobody likes it and if
> somebody finds a good way to kick it out then that will happen.
OK, but presumably I can't know whether or not someone who wrote a library
like pySerial relied on it or not. Although I suppose this is really a
documentation bug -- pySerial's documentation doesn't talk about
multi-threaded access directly, although their "minicom" example does
demonstrate it in action.
Thanks for the help,
---Joel
More information about the Python-list
mailing list