Doesn't this second decorator only work with functions doing IO or releasing the GIL in any other way (like time.sleep() that they use in the example)? If all the function is doing is actual computation (i.e. using the CPU), no other code can run in parallel with it because of the GIL.
Re:Python Concurrency Decorators
by thebigspacefuck on Friday May 13, 2016 @10:40AM
(#11690652)
Yes, that's right, it is best used for I/O-bound applications. You could use it for:
* running multiple Database queries
* SSH-ing into multiple devices to run a command
* loading multiple web pages
* calling multiple APIs
A lot of these need to be updated. For one, they don't follow PEP8.
Secondly, unfortunately, the signal thing doesn't work on Windows and the threading thing is a bad example because it simulates multiplication, but if you actually had a CPU intensive task, there would be no performance benefits.
Re:Python Concurrency Decorators
by stanislavb on Friday May 13, 2016 @03:46AM
(#11689171)
And here they are a few more decorators https://python.libhunt.com/categories/284-concurrency-and-pa...
Re:Python Concurrency Decorators
by hcarvalhoalves on Friday May 13, 2016 @12:53PM
(#11691508)
Never heard this name for this pattern (thunk). Isn't this the same as a Future/Promise object?
https://wiki.python.org/moin/PythonDecoratorLibrary
A similar decorator to thread function calls for concurrency:
https://wiki.python.org/moin/PythonDecoratorLibrary#Lazy_Thu...