From 216e470cd13a1039a8c109679e1d5f0709507ce4 Mon Sep 17 00:00:00 2001 From: fubuloubu <3859395+fubuloubu@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:44:01 -0400 Subject: [PATCH] refactor(example): made exmaple bot more multi-process friendly --- bots/example.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bots/example.py b/bots/example.py index 9322db2..eeb9512 100644 --- a/bots/example.py +++ b/bots/example.py @@ -37,14 +37,12 @@ async def grant_product(stream): async def update_product_funding(stream): # NOTE: properties of stream have changed, you may not need to handle this, but typically you # would want to update `stream.time_left` in db for use in user Stream life notifications - db[stream.creator].pop(stream.stream_id) - db[stream.creator].insert(stream.stream_id, stream) + db[stream.creator][stream.stream_id] = stream return stream.time_left @sm.on_stream_cancelled(app) async def revoke_product(stream): print(f"unprovisioning product for {stream.creator}") - db[stream.creator].pop(stream.stream_id) - db[stream.creator].insert(stream.stream_id, None) + db[stream.creator][stream.stream_id] = None return stream.time_left