News for hackers. Stuff that matters.
Re:Python Concurrency Decorators by thebigspacefuck on Thursday May 12, 2016 @03:08PM (#11685932)
Another page you might be interested in bookmarking:

https://wiki.python.org/moin/PythonDecoratorLibrary

A similar decorator to thread function calls for concurrency:

https://wiki.python.org/moin/PythonDecoratorLibrary#Lazy_Thu...

Re:Python Concurrency Decorators by elpres on Friday May 13, 2016 @04:08AM (#11689239)
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

Re:Python Concurrency Decorators by lqdc13 on Thursday May 12, 2016 @09:36PM (#11688067)
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)
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?
Re:Python Concurrency Decorators by issaria on Friday May 13, 2016 @03:11PM (#11692556)
Thunk is from haskell,.