How could I use requests in asyncio?

To use requests (or any other blocking libraries) with asyncio, you can use BaseEventLoop.run_in_executor to run a function in another thread and yield from it to get the result. For example: import asyncio import requests @asyncio.coroutine def main(): loop = asyncio.get_event_loop() future1 = loop.run_in_executor(None, requests.get, ‘http://www.google.com’) future2 = loop.run_in_executor(None, requests.get, ‘http://www.google.co.uk’) response1 = yield from … Read more

Python3: ImportError: No module named ‘_ctypes’ when using Value from module multiprocessing

Installing libffi-dev and re-installing python3.7 fixed the problem for me. to cleanly build py 3.7 libffi-dev is required or else later stuff will fail If using RHEL/Fedora: yum install libffi-devel or sudo dnf install libffi-devel If using Debian/Ubuntu: sudo apt-get install libffi-dev

Python type hinting without cyclic imports

There isn’t a hugely elegant way to handle import cycles in general, I’m afraid. Your choices are to either redesign your code to remove the cyclic dependency, or if it isn’t feasible, do something like this: # some_file.py from typing import TYPE_CHECKING if TYPE_CHECKING: from main import Main class MyObject(object): def func2(self, some_param: ‘Main’): … … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)