python - hid.find_all_hid_devices() in asyncio coroutine -
in order access a usb hid device connected on computer use function find_all_hid_devices()
from pywinusb
package.
now access hid device asyncio coroutine. following code
@asyncio.coroutine def main(): pywinusb import hid = hid.find_all_hid_devices()
the following error returned:
traceback (most recent call last): file "c:\python34\lib\site-packages\pywinusb\hid\core.py", line 122, in find_all_hid_devices interface_data in winapi.enum_device_interfaces(h_info, guid): file "c:\python34\lib\site-packages\pywinusb\hid\winapi.py", line 466, in enum_device_interfaces byref(dev_interface_data) ): ctypes.argumenterror: argument 1: <class 'overflowerror'>: int long convert
the same call hid.find_all_hid_devices()
works on own, in plain main without asyncio.
is due fact i'm trying access within coroutine? proper way achieve this?
pywinusb
library synchronous design, should call in thread pool.
@asyncio.coroutine def f(): loop = asyncio.get_event_loop() = yield loop.run_in_executor(none, hid.find_all_hid_devices)
synchronous call coroutine allowed technically discouraged because pauses event loop long time period.
Comments
Post a Comment