[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-22 Thread Kumar Aditya


Change by Kumar Aditya :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

> get_event_loop() is deprecated when there is no running event loop.

Yes, I see that now. So using asyncio.new_event_loop instead makes sense.

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

> I think there is no reason to replace all occurrences where get_event_loop() 
> works fine.

+1

I provided the grep for information only, hence FTR (for the record).

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

get_event_loop() is deprecated when there is no running event loop.
Otherwise, it is equal to get_running_loop() and IS NOT deprecated.

I think there is no reason to replace all occurrences where get_event_loop() 
works fine.

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

FTR, a rough grep for other users of get_event_loop in Lib/test (some false 
positives):

```
$ grep -rE "\" Lib/test
Lib/test/test_contextlib_async.py:loop = 
asyncio.get_event_loop_policy().get_event_loop()
Lib/test/test_asyncio/test_base_events.py:'loop = 
asyncio.get_event_loop()',
Lib/test/test_asyncio/test_windows_events.py:loop = 
asyncio.get_event_loop()
Lib/test/test_asyncio/test_runners.py:def get_event_loop(self):
Lib/test/test_asyncio/test_runners.py:loop = 
asyncio.get_event_loop()
Lib/test/test_asyncio/test_unix_events.py:
self.assertIsInstance(policy.get_event_loop(),
Lib/test/test_asyncio/test_unix_events.py:
policy.get_event_loop().close()
Lib/test/test_asyncio/test_unix_events.py:loop = policy.get_event_loop()
Lib/test/test_asyncio/test_events.py:
self.assertRaises(NotImplementedError, policy.get_event_loop)
Lib/test/test_asyncio/test_events.py:loop = policy.get_event_loop()
Lib/test/test_asyncio/test_events.py:self.assertIs(loop, 
policy.get_event_loop())
Lib/test/test_asyncio/test_events.py:loop = policy.get_event_loop()
Lib/test/test_asyncio/test_events.py:self.assertRaises(RuntimeError, 
policy.get_event_loop)
Lib/test/test_asyncio/test_events.py:
self.assertRaises(RuntimeError, policy.get_event_loop)
Lib/test/test_asyncio/test_events.py:old_loop = policy.get_event_loop()
Lib/test/test_asyncio/test_events.py:self.assertIs(loop, 
policy.get_event_loop())
Lib/test/test_asyncio/test_events.py:self.assertIsNot(old_loop, 
policy.get_event_loop())
Lib/test/test_asyncio/test_events.py:self.get_event_loop_saved = 
events.get_event_loop
Lib/test/test_asyncio/test_events.py:events.get_event_loop = 
type(self).get_event_loop_impl
Lib/test/test_asyncio/test_events.py:asyncio.get_event_loop = 
type(self).get_event_loop_impl
Lib/test/test_asyncio/test_events.py:events.get_event_loop = 
self.get_event_loop_saved
Lib/test/test_asyncio/test_events.py:asyncio.get_event_loop = 
self.get_event_loop_saved
Lib/test/test_asyncio/test_events.py:def get_event_loop(self):
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:
self.assertIs(asyncio.get_event_loop(), loop)
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:loop2 = 
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
Lib/test/test_asyncio/test_events.py:
self.assertIs(asyncio.get_event_loop(), loop)
Lib/test/test_asyncio/test_events.py:
self.assertIs(asyncio.get_event_loop(), loop)
Lib/test/test_asyncio/test_events.py:
asyncio.get_event_loop()
```

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Erlend E. Aasland


Erlend E. Aasland  added the comment:

Kumar, did you consider using get_running_loop() to retrieve the event loop in 
the current thread, instead of creating a new one?

--

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-11 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

Providing some more background, based on the changes proposed by Kumar in 
GH-30486:

asyncio.get_event_loop() was marked as deprecated in Python 3.10. Quoting from 
the asyncio documentation , 
https://docs.python.org/3/library/asyncio-eventloop.html (as of 3.10):

Because this function has rather complex behavior (especially when custom
event loop policies are in use), using the get_running_loop() function is
preferred to get_event_loop() in coroutines and callbacks.

[...]

Deprecated since version 3.10: Deprecation warning is emitted if there is
no running event loop. In future Python releases, this function will be an
alias of get_running_loop().


GH-30486 proposes to replace asyncio.get_event_loop() with 
asyncio.new_event_loop().

--
nosy: +erlendaasland

___
Python tracker 

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



[issue46340] DeprecationWarning emitted when running asyncio tests

2022-01-10 Thread Kumar Aditya


Change by Kumar Aditya :


--
components: asyncio
nosy: asvetlov, kumaraditya303, yselivanov
priority: normal
pull_requests: 28727
severity: normal
status: open
title: DeprecationWarning emitted when running asyncio tests
versions: Python 3.11

___
Python tracker 

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