crossbario/txaio

Support import time framework selection

om26er opened this issue · 3 comments

Currently to use txaio we have to either call use_twisted() or use_asyncio() at the start of a python file, while it works great, it doesn't look good. flake8 doesn't like that as well since we add more imports after the use_twisted() call.

It would be good if the library had a way to select the framework on import, something along the lines

from txaio import with_twisted as txaio

yeah, I agree, would look nicer to have it hidden in the import.

to silence flake8 with the existing method:

import txaio
txaio.use_twisted()  # noqa

Ultimately, the idea is to have the framework selected by imports anyway (i.e. in the user-code, Autobahn). That is, have the .use_X() call inside import autobahn.twisted.* so we could clean that up a little by doing it. Could be as easy as a "with_twisted.py" file that just imports and calls .use_twisted()

I took a stab at that here #156