[issue27929] asyncio.AbstractEventLoop.sock_connect broken for AF_BLUETOOTH

2022-03-26 Thread Vincent Bernat


Change by Vincent Bernat :


--
keywords: +patch
nosy: +bernat
nosy_count: 4.0 -> 5.0
pull_requests: +30211
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/32131

___
Python tracker 
<https://bugs.python.org/issue27929>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44665] asyncio.create_task() documentation should mention user needs to keep reference to the task

2021-07-17 Thread Vincent Bernat


New submission from Vincent Bernat :

asyncio will only keep weak references to alive tasks (in `_all_tasks`). If a 
user does not keep a reference to a task and the task is not currently 
executing or sleeping, the user may get "Task was destroyed but it is pending!".

I would suggest adding the following paragraph to `create_task()` documentation:

Python only keeps weak references to the scheduled tasks. To avoid the task 
being destroyed by the garbage collector while still pending, a reference to it 
should be kept until the task is done.

And maybe an example in case a user wants something "fire and forget"?

```python
running_tasks = set()
# [...]
task = asyncio.create_task(some_background_function())
running_tasks.add(task)
task.add_done_callback(lambda t: running_tasks.remove(t))
```

The same applies to ensure_future as it now uses create_task, so maybe a "See 
create_task()".

--
assignee: docs@python
components: Documentation
messages: 397741
nosy: bernat, docs@python
priority: normal
severity: normal
status: open
title: asyncio.create_task() documentation should mention user needs to keep 
reference to the task
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue44665>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44665] asyncio.create_task() documentation should mention user needs to keep reference to the task

2021-10-22 Thread Vincent Bernat


Vincent Bernat  added the comment:

Hummm, I have a hard time finding a short example when `__del__` is not called 
until the task is finished. Sorry. I did run into this several time, for 
example here: https://github.com/ldo/dbussy/pull/45 (and some internal projects 
as well). So, it happens from time to time, but it is hard to find a simple 
reproducer.

--

___
Python tracker 
<https://bugs.python.org/issue44665>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com