[issue30083] Asyncio: GeneratorExit + strange exception

2020-09-18 Thread Guilherme Salgado


Guilherme Salgado  added the comment:

I've also been affected by this and found that if you use asyncio.run() the 
coroutine is interrupted with a CancelledError as you'd expect. The following 
script shows that

===
import asyncio

async def handle_connection(reader, writer):
try:
await reader.readexactly(42)
except BaseException as err:
print('Interesting: %r.' % err)
raise
finally:
writer.close()

async def main():
listener = await asyncio.start_server(handle_connection, '127.0.0.1', )
try:
async with listener:
await listener.serve_forever()
except KeyboardInterrupt:
print('KeyboardInterrupt')

asyncio.run(main())
=

--
nosy: +salgado

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



[issue39116] StreamReader.readexactly() raises GeneratorExit on ProactorEventLoop

2020-08-26 Thread Guilherme Salgado


Change by Guilherme Salgado :


--
nosy: +salgado

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



[issue40152] Coroutine hangs if it performs async operations when handling exception sent using throw()

2020-04-02 Thread Guilherme Salgado


Change by Guilherme Salgado :


--
versions: +Python 3.8

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



[issue40152] Coroutine hangs if it performs async operations when handling exception sent using throw()

2020-04-02 Thread Guilherme Salgado


New submission from Guilherme Salgado :

A coroutine will hang forever if it that catches an exception sent via its 
throw() method and then makes async calls while handling that exception. The 
same coroutine will complete just fine if the exception is instead raised from 
within it. Here's a script that demonstrates that:

```
import asyncio
import sys

async def sleep_on_exc(inject):
if inject:
asyncio.ensure_future(inject_exc(coro))
try:
await asyncio.sleep(0.2)
if not inject:
print("Raising KeyboardInterrupt")
raise KeyboardInterrupt()
except KeyboardInterrupt:
print("I'm not done yet")
await asyncio.sleep(0.1)
print("Now I'm done")

async def inject_exc(coro):
await asyncio.sleep(0.1)
print("Injecting KeyboardInterrupt")
coro.throw(KeyboardInterrupt)

coro = sleep_on_exc(sys.argv[1] == "inject")
loop = asyncio.get_event_loop()
loop.run_until_complete(coro)
```

```
$ python throw.py raise
Raising KeyboardInterrupt
I'm not done yet
Now I'm done
```

```
$ python throw.py inject
Injecting KeyboardInterrupt
I'm not done yet # It hangs forever here until you Ctrl-C
^CTraceback (most recent call last):
...
```

--
components: asyncio
messages: 365572
nosy: asvetlov, salgado, yselivanov
priority: normal
severity: normal
status: open
title: Coroutine hangs if it performs async operations when handling exception 
sent using throw()
type: behavior
versions: Python 3.7

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



[issue34098] multiprocessing.Server swallows original exception traceback

2018-07-11 Thread Guilherme Salgado


New submission from Guilherme Salgado :

multiprocessing.Server swallows original exception traceback, making it hard to 
debug. For example, the following code:

```
from multiprocessing.managers import BaseManager

class FooBar(object):
def m(self):
self._raise()
def _raise(self):
raise ValueError

class MyManager(BaseManager):
pass

MyManager.register('Foo', callable=FooBar)
manager = MyManager()
manager.start()
manager.Foo()._callmethod('m')
manager.shutdown()
```
Gives me the following exception:

```
Traceback (most recent call last):
  File "/tmp/foo.py", line 15, in 
manager.Foo()._callmethod('m')
  File "/usr/lib/python3.6/multiprocessing/managers.py", line 772, in 
_callmethod
raise convert_to_error(kind, result)
ValueError
```

Ideally, I'd like to get something like this:

```
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/salgado/src/cpython/Lib/multiprocessing/managers.py", line 254, 
in serve_client
res = function(*args, **kwds)
  File "/tmp/foo.py", line 5, in m
self._raise()
  File "/tmp/foo.py", line 7, in _raise
raise ValueError
ValueError
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tmp/foo.py", line 15, in 
manager.Foo()._callmethod('m')
  File "/home/salgado/src/cpython/Lib/multiprocessing/managers.py", line 811, 
in _callmethod
raise convert_to_error(kind, result)
ValueError
```

--
components: Library (Lib)
messages: 321480
nosy: salgado
priority: normal
severity: normal
status: open
title: multiprocessing.Server swallows original exception traceback
type: enhancement
versions: Python 3.8

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



[issue7946] Convoy effect with I/O bound threads and New GIL

2010-04-27 Thread Guilherme Salgado

Changes by Guilherme Salgado gsalg...@gmail.com:


--
nosy:  -salgado

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7946
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7946] Convoy effect with I/O bound threads and New GIL

2010-03-26 Thread Guilherme Salgado

Changes by Guilherme Salgado gsalg...@gmail.com:


--
nosy: +salgado

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7946
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com