View Code? Open in Web Editor
NEW
Async wrapper for requests / aiohttp, and some crawler toolkits. Let synchronization code enjoy the performance of asynchronous programming.
Home Page: https://torequests.readthedocs.io/en/latest/
License: MIT License
torequests's People
Contributors
torequests's Issues
Mock server
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse
app = Starlette()
@app.route("/")
async def source_redirect(req):
return PlainTextResponse('ok')
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, port=9890)
Windows10, without uvloop.
The PyPI releases do not include tests, and there are no GitHub releases, so I can not get a stable URL for fetching tests of a release
from torequests.utils import timeago
print(timeago(234, format=1))
# 3 minutes 54 seconds 0 ms # remove 0 ms
print(timeago(360, format=1))
# 6 minutes 0 second 0 ms # remove 0 second 0 ms
shell backslash-escaped string parsed failed.
- \n \r
- '
Waiting for websocket support.
block............
expect concurrently running with different host
got Future attached to a different loop
async with sem
will lead to lose performance for benchmark, so remove it while no explicit sem
from torequests.main import threads, time
from torequests.utils import Timer
from torequests.dummy import Requests as tPool
from torequests import tPool
Timer()
req= tPool(n=1, interval=2)
ss=[]
ss = [req.get('http://p.3.cn', callback=lambda r: print(ss)) for i in range(5)]
time.sleep(1)
print(ss)
req.x
`
if __name__ == '__main__':
from gevent import monkey
monkey.patch_all()
from torequests import tPool
# from torequests.dummy import Requests as tPool
req = tPool()
r = req.get('http://baidu.com', callback=lambda r: print(r))
print(r.result(1))
print('done')
gevent/gevent#1251
Queue strategy is very slow and takes large memory.
Implementing a generator version