Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This module brings the ease and clearity of functionnal programming into the world of multiprocessing and multithreading in Python
The name stands for functIONNAL multiPROCESSing
The project goals are basically:
Starting with notorious alternatives, from a user perspective:
multiprocessing
, mpi
and other multiprocessing tools are not functionnal style
threading
and other threading tools are not functionnal style
grpc
or similar remote process call systems bring a lot of friction
multiprocessing
performances are unsatisfying
processional
aims to bring an answer to these problems using the functionnal and asynchronous programming paradigms and the dynamic languages features
Since Colesbury brought a solution to the GIL , splitting a python program across processes to acheive parallelism will soon no longer be required, so this module will loose a bit of its interest. Anyway this library also features threads, and parallelism is not the only reason of multiprocessing so this project does not seem vain.
Everything in this module is about executing heavy things (resources or computations) in the background.
a Thread
is the default choice for this:
def heavy_work(x):
return sum(x)
def foo():
heavy_resource = list(range(1_000_000))
return heavy_work(heavy_resource)
# use a thread to perform this task
task = thread(foo)
print('and the result is ...')
print(task.wait())
and the result is ...
499999500000
But sometimes you need to keep your heavy resource alive for several tasks. You might simply keep a reference to this resource in your main thread and run a second thread later, but some objects (like Gui objects, or any non thread-safe objects) need to be run or held by one only thread. So you have to communicate your orders to this thread: this is called thread invocation.
a SlaveThread
is the way to work around this:
from functools import reduce
from operator import mul
thread = SlaveThread()
heavy_resource = thread.invoke(lambda: list(range(1_000_000)))
heavy_work_1 = thread.schedule(lambda: sum(heavy_resource))
heavy_work_2 = thread.schedule(lambda: reduce(mul, heavy_resource))
print('summing')
print('multiplying')
print('sum is', heavy_work_1.wait())
print('product is', heavy_work_2.wait())
summing
multiplying
sum is 499999500000
product is 0
A further need is to achieve the same as the two previous, but on a remote computer or in a separate process (in order to distribute the load on a network, or to gain parallelism, or to benefit from other machine's hardwares). This is called Remote Process Call (RPC)
a SlaveProcess
is answering this need:
from functools import reduce
from operator import mul
process = slave() # spawn and connect, the result is a SlaveProcess
heavy_resource = process.wrap(lambda: list(range(1_000_000)))
heavy_work_1 = process.schedule(lambda: sum(heavy_resource))
heavy_work_2 = process.schedule(lambda: reduce(mul, heavy_resource))
print('summing')
print('multiplying')
print('sum is', heavy_work_1.wait())
print('product is', heavy_work_2.wait())
summing
multiplying
sum is 499999500000
product is 0
A last need is to send commands from multiple machines or processes to the same remote process (allowing multiple machines to use a shared ressources in the remote process). In this situation, the communication style changes from master-slave to client-server
a SlaveProcess
also handles that:
# in process 1
process = server('/tmp/server') # spawn and connect, the result is a SlaveProcess
@process.schedule
def init_global():
global heavy_resource
heavy_resource = list(range(1_000_000))
heavy_work_1 = process.schedule(lambda: sum(heavy_resource))
print('summing')
print('sum is', heavy_work1.wait())
# in process 2
from functools import reduce
from operator import mul
process = client('/tmp/server') # connect, the result is a SlaveProcess
heavy_work_2 = process.schedule(lambda: reduce(mul, heavy_resource))
print('multiplying')
print('product is', heavy_work_2.wait())
summing
multiplying
sum is 499999500000
product is 0
While multiprocessing, this library uses pickle
to send objects between processes and thus TRUST the remote side completely. Do not use this library to control tasks on a remote machine you do not trust.
Since SSL tunelling is not yet implemented here, do not use this library either if the communication between processes can be intercepted (network or OS)
Basically this library is meant to be used when all processes remote or not are communicating in a secured and closed environment, just like components in one computer.
Feature | Unix Python >= 3.9 | Windows Python >= 3.9 |
---|---|---|
threads with results | X | X |
slave threads | X | X |
interruptible threads | X | X |
slave process | X | |
server process through tcp/ip (local or remote | X | X |
server process through unix sockets (faster) | X | |
shared memory | X |
This project in its published version has only been tested on small applications. However one of its previous and less complete version had been running programs with ~20 threads and ~10 processes exchanging very frequently all the time (big images, complex data structures, etc) on an industrial machine for over 2 years with no issue.
All this is made possible by
FAQs
multiprocess and multithread functional programming library
We found that processional demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.