mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Fix tests for Python 3.11
This commit is contained in:
parent
ec50cc7c0d
commit
2d74d1ad94
@ -39,7 +39,7 @@ class Pool():
|
||||
while len(self._tasks) > 0 or len(pending) > 0:
|
||||
while len(self._tasks) > 0 and len(pending) < self._concurrency:
|
||||
task, args, kwargs = self._tasks.pop(0)
|
||||
pending.add(task(*args, **kwargs))
|
||||
pending.add(asyncio.create_task(task(*args, **kwargs)))
|
||||
(done, pending) = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)
|
||||
for task in done:
|
||||
if task.exception():
|
||||
|
@ -164,8 +164,6 @@ class Route(object):
|
||||
"description": kw.get("description", ""),
|
||||
})
|
||||
|
||||
func = asyncio.coroutine(func)
|
||||
|
||||
async def control_schema(request):
|
||||
# This block is executed at each method call
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
@ -181,7 +179,10 @@ class Route(object):
|
||||
response = Response(request=request, route=route, output_schema=output_schema)
|
||||
|
||||
request = await parse_request(request, None, raw)
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
await func(request, response)
|
||||
else:
|
||||
func(request, response)
|
||||
return response
|
||||
|
||||
# API call
|
||||
@ -195,7 +196,10 @@ class Route(object):
|
||||
except OSError as e:
|
||||
log.warning("Could not write to the record file {}: {}".format(record_file, e))
|
||||
response = Response(request=request, route=route, output_schema=output_schema)
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
await func(request, response)
|
||||
else:
|
||||
func(request, response)
|
||||
except aiohttp.web.HTTPBadRequest as e:
|
||||
response = Response(request=request, route=route)
|
||||
response.set_status(e.status)
|
||||
|
Loading…
Reference in New Issue
Block a user