Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asyncio interfaces #118

Closed
Jaymon opened this issue Oct 10, 2021 · 2 comments · Fixed by #121
Closed

Asyncio interfaces #118

Jaymon opened this issue Oct 10, 2021 · 2 comments · Fixed by #121

Comments

@Jaymon
Copy link
Owner

Jaymon commented Oct 10, 2021

Now that python2 support has been dropped I think I will add asyncio support with the ASGI interface. After some tests, it looks like I can have the async and sync interfaces be the same, the sync will just extend the async interface and wrap all the methods, something like:

class AsyncFoo(object):
    async def foo(self, ret_value, sleep=1):
        print("async")
        await asyncio.sleep(sleep)
        print("foo")
        return value


class SyncFoo(AsyncFoo):
    def foo(self, *args, **kwargs):
        return asyncio.run(super().foo(*args, **kwargs))


f = SyncFoo()
print(f.foo(6))

This works in my tests and so, hopefully, something similar to my tests will actually work when implemented so I can keep the interfaces the same and then it's just a choice on what to use.

Links I had open

Search

  • does python asyncio need monkey patching
  • python async
This was referenced Oct 10, 2021
@Jaymon
Copy link
Owner Author

Jaymon commented Oct 20, 2021

uWSGI and async:

search:

  • uwsgi asyncio

@Jaymon
Copy link
Owner Author

Jaymon commented Oct 20, 2021

Jaymon/caches#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant