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 library helps you execute a set of functions in a Directed Acyclic Graph (DAG) dependency structure in parallel in a production environment.
Tawazi facilitates parallel execution of functions using a DAG dependency structure.
Consider the function f
that depends on the function g
and h
:
def g():
print("g")
return "g"
def h():
print("h")
return "h"
def f(g_var, h_var):
print("received", g_var, h_var)
print("f")
return "f"
def main():
f(g(), h())
main()
The DAG described in main
can be accelerated if g
and h
are executed in parallel. This is what Tawazi does by adding a decorator to the functions g
, h
, f
, and main
:
from tawazi import dag, xn
@xn
def g():
print("g")
return "g"
@xn
def h():
print("h")
return "h"
@xn
def f(g_var, h_var):
print("received", g_var, h_var)
print("f")
return "f"
@dag(max_concurrency=2)
def main():
f(g(), h())
main()
The total execution time of main()
is 1 second instead of 2 which proves that the g
and h
have run in parallel, you can measure the speed up in the previous code:
from time import sleep, time
from tawazi import dag, xn
@xn
def g():
sleep(1)
print("g")
return "g"
@xn
def h():
sleep(1)
print("h")
return "h"
@xn
def f(g_var, h_var):
print("received", g_var, h_var)
print("f")
return "f"
@dag(max_concurrency=2)
def main():
f(g(), h())
start = time()
main()
end = time()
print("time taken", end - start)
# h
# g
# received g h
# f
# time taken 1.004307508468628
This library satisfies the following:
In Tawazi, a computation sequence is referred to as DAG
. The functions invoked inside the computation sequence are referred to as ExecNode
s.
Current features are:
DAG
usesExecNode
s: These nodes only run once per DAG instanceExecNode
s: These are nodes that run only if RUN_DEBUG_NODES
environment variable is setDAG
instanceExecNode
from runningDAG
for faster subsequent executionExecNode
for fine control of execution orderExecNode
choice of parallelization (i.e. An ExecNode
is allowed to run in parallel with other ExecNode
s or not)You can find the documentation here: Tawazi.
In this blog we also talk about the purpose of using Tawazi
in more detail.
Note: The library is still at an advanced state of development. Breaking changes might happen on the minor version (v0.Minor.Patch). Please pin Tawazi to the Minor Version. Your contributions are highly welcomed.
The libraries name is inspired from the arabic word تَوَازٍ which means parallel.
Only the latest version's documentation is hosted.
If you want to check the documentation of a previous version please checkout the corresponding release, install the required packages and run: mkdocs serve
pip install --upgrade pip
pip install flit wheel
cd tawazi
flit install -s --deps develop
This library is still in development. Breaking changes are expected.
FAQs
This library helps you execute a set of functions in a Directed Acyclic Graph (DAG) dependency structure in parallel in a production environment.
We found that tawazi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.