https://dagster.io/ logo
Title
r

Ryan Navaroli

10/18/2022, 7:14 PM
Question, I need to use an SDK for nats.io that requires
asyncio
for everything, but dagster seems to lack support for
asyncio
with `@sensor`s. So basically calling any nats function (like creating a connection) requires an
await
keyword, which can only be used within an
async def
function. But dagster sensor needs to be set up as a synchronous
def
function, which makes it very difficult to integrate with the nats sdk. Any suggestions on how have an
async @sensor
or how to work around?
:dagster-bot-responded-by-community: 1
a

Adam Bloom

10/18/2022, 7:29 PM
any reason you can't have a non-async sensor that runs your event loop/coroutines? All asyncio functions in python will have a parent function that isn't async. asyncio.run is your friend here: https://docs.python.org/3/library/asyncio-task.html (there are definitely more complex things you can do with event loops, depends on how complex your interaction with nats.io is)
r

Ryan Navaroli

10/18/2022, 7:43 PM
Oh got it, I'm not too versed in Python but this looks right and makes sense to me. Will have to try it out. Thanks!