File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,11 @@ def __init__(self, address: str) -> None:
59
59
self .address = address
60
60
self .model = redis .from_url (self .address )
61
61
62
- self .loop = asyncio .new_event_loop ()
62
+ # Get Existing loop, create one if it doesn't exist
63
+ try :
64
+ self .loop = asyncio .get_running_loop ()
65
+ except RuntimeError :
66
+ self .loop = asyncio .new_event_loop ()
63
67
64
68
def store (self , key : str , item : str = "value" ) -> None :
65
69
"""Store a key value pair in the provided redis server.
Original file line number Diff line number Diff line change @@ -199,7 +199,14 @@ def usgs_earthquake_data(
199
199
200
200
click .echo ("Post mode enabled: Sending data..." )
201
201
click .echo (f"Querying redis at { backpack_dispatcher .redis .address } " )
202
- asyncio .run (backpack_dispatcher .direct_connect ())
202
+
203
+ # Get Existing loop, create one if it doesn't exist
204
+ try :
205
+ loop = asyncio .get_running_loop ()
206
+ except RuntimeError :
207
+ loop = asyncio .new_event_loop ()
208
+
209
+ loop .run_until_complete (backpack_dispatcher .direct_connect ())
203
210
204
211
click .echo ("complete" )
205
212
You can’t perform that action at this time.
0 commit comments