Python Concurrency Decorators
github.com
github.com
https://wiki.python.org/moin/PythonDecoratorLibrary
A similar decorator to thread function calls for concurrency:
https://wiki.python.org/moin/PythonDecoratorLibrary#Lazy_Thu...
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.
* running multiple Database queries
* SSH-ing into multiple devices to run a command
* loading multiple web pages
* calling multiple APIs
The other thing is that this won't work on Windows. Efficient multiprocessing always a pain in Python in my experience.
- It has Python 2 and 3 support
- It's a wrapper for the Python built-in "multiprocessing" library
- It spreads out work over all cores (so the abstraction hides the ability to control the pool)
Seems like a great way to get your feet wet with multiprocessing in Python, but it likely has limited use in production...although certain infrastructures like resource limited containers might be able to accommodate it.
> That's it, two lines of changes is all we need in order to parallelize this program. Now this program will make use of all the cores on the machine it's running on, allowing it to run significantly faster.
> As an overview, DECO is mainly just a smart wrapper for Python's multiprocessing.pool. When @concurrent is applied to a function it replaces it with calls to pool.apply_async. Additionally when arguments are passed to pool.apply_async, DECO replaces any index mutable objects with proxies, allowing it to detect and synchronize mutations of these objects. The results of these calls can then be obtained by calling wait() on the concurrent function, invoking a synchronization event.
I haven't really dug around the source code, but it sounds like not really.
https://github.com/alex-sherman/deco/blob/cee63391bf4c6d66ee...
1. https://github.com/alex-sherman/deco/blob/master/conc_test.p...
https://github.com/alex-sherman/deco/blob/cee63391bf4c6d66ee...
This applies to programs that run Python bytecode in multiple threads in the same process. Multiprocessing forks multiple processes, so there is no GIL issue.
For simple usage if you are familiar with Go there is this library: https://github.com/pothos/awaitchannel
There have been few commits to fix compatibility, but it's not there yet.
gave me the chills
Multiprocessing gets pretty useless for anything outside of independent CPU bound tasks with little IPC and simple data types that can be stuck into shared memory.
If you're using multiprocessing pools so often that you think you need a decorator to clean up your code, then wow, I'd like to see what you're up to. ;)
that said I really like the idea of using inner and outer function calls as a hook for spawning and collecting promises. it doesn't only have to be a join on a CPU-bound worker pool; this feels like a cleaner way to abstract IO waits than the yield statements I saw in an early prototype of tulip.
In general, this feels like a clean way to compose any library logic that involves an event loop or execution plan rather than just a function call.
.. and I think once you do that in Python you should probably use NumPy.
I've been thinking that there should be a way to just program kernels in Modern Fortran because it's the easiest to interact with NumPy data structures (NumPy is nothing but glue code around a collection of very efficient Fortran numeric code). f2py [1] is doing that basically, but I've never had the chance to setup a project like this.
[1] http://docs.scipy.org/doc/numpy-1.10.1/user/c-info.python-as...