mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-20 16:52:08 -05:00
feat: concurrency groups (#135)
* first pass at moving controllers around * feat: concurrency limits for strategy CANCEL_IN_PROGRESS * fix: linting * chore: bump python sdk version
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
from hatchet_sdk import new_client
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
client = new_client()
|
||||
|
||||
client.event.push(
|
||||
"concurrency-test",
|
||||
{
|
||||
"test": "test"
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,32 @@
|
||||
from hatchet_sdk import Hatchet
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
hatchet = Hatchet(debug=True)
|
||||
|
||||
@hatchet.workflow(on_events=["concurrency-test"])
|
||||
class ConcurrencyDemoWorkflow:
|
||||
def __init__(self):
|
||||
self.my_value = "test"
|
||||
|
||||
@hatchet.concurrency(max_runs=5)
|
||||
def concurrency(self, context) -> str:
|
||||
return "concurrency-key"
|
||||
|
||||
@hatchet.step()
|
||||
def step1(self, context):
|
||||
print("executed step1")
|
||||
pass
|
||||
|
||||
@hatchet.step(parents=["step1"],timeout='4s')
|
||||
def step2(self, context):
|
||||
print("started step2")
|
||||
context.sleep(1)
|
||||
print("finished step2")
|
||||
|
||||
workflow = ConcurrencyDemoWorkflow()
|
||||
worker = hatchet.worker('concurrency-demo-worker', max_threads=4)
|
||||
worker.register_workflow(workflow)
|
||||
|
||||
worker.start()
|
||||
Reference in New Issue
Block a user