Skip to content

Commit

Permalink
Merge branch 'task-name-3.7' of github.com:sanic-org/sanic into task-…
Browse files Browse the repository at this point in the history
…name-3.7
  • Loading branch information
ahopkins committed Jan 5, 2022
2 parents 458a4ea + f0e30b1 commit 7f76eda
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sanic/app.py
Expand Up @@ -1552,16 +1552,17 @@ def _loop_add_task(
name: Optional[str] = None,
register: bool = True,
) -> Task:
prepped = cls._prep_task(task, app, loop)
if sys.version_info == (3, 7):
if name:
error_logger.warning(
"Cannot set a name for a task when using Python 3.7. Your "
"task will be created without a name."
)
task = loop.create_task(prepped)
else:
task = loop.create_task(prepped, name=name)
if not isinstance(task, Future):
prepped = cls._prep_task(task, app, loop)
if sys.version_info == (3, 7):
if name:
error_logger.warning(
"Cannot set a name for a task when using Python 3.7. Your "
"task will be created without a name."
)
task = loop.create_task(prepped)
else:
task = loop.create_task(prepped, name=name)

if name and register and sys.version_info > (3, 7):
app._task_registry[name] = task
Expand Down

0 comments on commit 7f76eda

Please sign in to comment.