Python traceback for coroutineHow can I represent an 'Enum' in Python?Way to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”How to catch exceptions in async / await based single-threaded coroutine implementationAsync/await as a replacement of coroutinesWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Python native coroutines and send()How to inspect program state in the presence of generators/coroutines?C++1z coroutine threading context and coroutine schedulingCan a Python coroutine be implemented without await or yield?
Can I still be respawned if I die by falling off the map?
What is Cash Advance APR?
Is this toilet slogan correct usage of the English language?
What should you do if you miss a job interview (deliberately)?
Can a Canadian Travel to the USA twice, less than 180 days each time?
Why does a simple loop result in ASYNC_NETWORK_IO waits?
How to hide some fields of struct in C?
PTIJ: Haman's bad computer
Is there a way to get `mathscr' with lower case letters in pdfLaTeX?
Why is the "ls" command showing permissions of files in a FAT32 partition?
Can a stoichiometric mixture of oxygen and methane exist as a liquid at standard pressure and some (low) temperature?
Is there a RAID 0 Equivalent for RAM?
Picking the different solutions to the time independent Schrodinger eqaution
What happens if you are holding an Iron Flask with a demon inside and walk into an Antimagic Field?
Is aluminum electrical wire used on aircraft?
Can the US President recognize Israel’s sovereignty over the Golan Heights for the USA or does that need an act of Congress?
What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?
What is the English pronunciation of "pain au chocolat"?
How do apertures which seem too large to physically fit work?
What is the highest possible scrabble score for placing a single tile
On a tidally locked planet, would time be quantized?
Why would a new[] expression ever invoke a destructor?
What does chmod -u do?
What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?
Python traceback for coroutine
How can I represent an 'Enum' in Python?Way to create multiline comments in Python?What is the Python 3 equivalent of “python -m SimpleHTTPServer”How to catch exceptions in async / await based single-threaded coroutine implementationAsync/await as a replacement of coroutinesWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?Python native coroutines and send()How to inspect program state in the presence of generators/coroutines?C++1z coroutine threading context and coroutine schedulingCan a Python coroutine be implemented without await or yield?
Let's say I have the following code:
from types import coroutine
@coroutine
def stop():
yield 1
async def test2():
await stop()
async def test1():
await test2()
await test2() # Here
await test2()
coro = test1()
coro.send(None)
coro.send(None)
How can I get traceback (traceback object) for current coroutine state, i.e. line marked with comment, without artificially throwing unneeded exception?
python-3.x python-asyncio coroutine
add a comment |
Let's say I have the following code:
from types import coroutine
@coroutine
def stop():
yield 1
async def test2():
await stop()
async def test1():
await test2()
await test2() # Here
await test2()
coro = test1()
coro.send(None)
coro.send(None)
How can I get traceback (traceback object) for current coroutine state, i.e. line marked with comment, without artificially throwing unneeded exception?
python-3.x python-asyncio coroutine
add a comment |
Let's say I have the following code:
from types import coroutine
@coroutine
def stop():
yield 1
async def test2():
await stop()
async def test1():
await test2()
await test2() # Here
await test2()
coro = test1()
coro.send(None)
coro.send(None)
How can I get traceback (traceback object) for current coroutine state, i.e. line marked with comment, without artificially throwing unneeded exception?
python-3.x python-asyncio coroutine
Let's say I have the following code:
from types import coroutine
@coroutine
def stop():
yield 1
async def test2():
await stop()
async def test1():
await test2()
await test2() # Here
await test2()
coro = test1()
coro.send(None)
coro.send(None)
How can I get traceback (traceback object) for current coroutine state, i.e. line marked with comment, without artificially throwing unneeded exception?
python-3.x python-asyncio coroutine
python-3.x python-asyncio coroutine
asked yesterday
adontzadontz
8681029
8681029
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use of traceback.print_stack()
will give you the exact same traceback as thrown exception:
async def test1():
await test2()
traceback.print_stack()
# raise Exception()
await test2() # Here
await test2()
You can use traceback.extract_stack() if you want to recieve object instead of printing.
Note however that you're doing something strange. asyncio
coroutines is not supposed to be run use it's generator's nature functions like .send()
.
In asyncio
you await for coroutines and run top level coroutine using event loop. Please see how it's done in documentation.
I write another small example that shows how to print start inside inner coroutine when you use asyncio
regular way:
import asyncio
import traceback
async def test3():
traceback.print_stack()
async def test2():
await test3()
async def test1():
await test2()
asyncio.run(test1())
You'll see:
File "C:main.py", line 24, in <module>
asyncio.run(test1())
# inner event loop stack here
File "C:main.py", line 21, in test1
await test2()
File "C:main.py", line 17, in test2
await test3()
File "C:main.py", line 13, in test3
traceback.print_stack()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280869%2fpython-traceback-for-coroutine%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use of traceback.print_stack()
will give you the exact same traceback as thrown exception:
async def test1():
await test2()
traceback.print_stack()
# raise Exception()
await test2() # Here
await test2()
You can use traceback.extract_stack() if you want to recieve object instead of printing.
Note however that you're doing something strange. asyncio
coroutines is not supposed to be run use it's generator's nature functions like .send()
.
In asyncio
you await for coroutines and run top level coroutine using event loop. Please see how it's done in documentation.
I write another small example that shows how to print start inside inner coroutine when you use asyncio
regular way:
import asyncio
import traceback
async def test3():
traceback.print_stack()
async def test2():
await test3()
async def test1():
await test2()
asyncio.run(test1())
You'll see:
File "C:main.py", line 24, in <module>
asyncio.run(test1())
# inner event loop stack here
File "C:main.py", line 21, in test1
await test2()
File "C:main.py", line 17, in test2
await test3()
File "C:main.py", line 13, in test3
traceback.print_stack()
add a comment |
Use of traceback.print_stack()
will give you the exact same traceback as thrown exception:
async def test1():
await test2()
traceback.print_stack()
# raise Exception()
await test2() # Here
await test2()
You can use traceback.extract_stack() if you want to recieve object instead of printing.
Note however that you're doing something strange. asyncio
coroutines is not supposed to be run use it's generator's nature functions like .send()
.
In asyncio
you await for coroutines and run top level coroutine using event loop. Please see how it's done in documentation.
I write another small example that shows how to print start inside inner coroutine when you use asyncio
regular way:
import asyncio
import traceback
async def test3():
traceback.print_stack()
async def test2():
await test3()
async def test1():
await test2()
asyncio.run(test1())
You'll see:
File "C:main.py", line 24, in <module>
asyncio.run(test1())
# inner event loop stack here
File "C:main.py", line 21, in test1
await test2()
File "C:main.py", line 17, in test2
await test3()
File "C:main.py", line 13, in test3
traceback.print_stack()
add a comment |
Use of traceback.print_stack()
will give you the exact same traceback as thrown exception:
async def test1():
await test2()
traceback.print_stack()
# raise Exception()
await test2() # Here
await test2()
You can use traceback.extract_stack() if you want to recieve object instead of printing.
Note however that you're doing something strange. asyncio
coroutines is not supposed to be run use it's generator's nature functions like .send()
.
In asyncio
you await for coroutines and run top level coroutine using event loop. Please see how it's done in documentation.
I write another small example that shows how to print start inside inner coroutine when you use asyncio
regular way:
import asyncio
import traceback
async def test3():
traceback.print_stack()
async def test2():
await test3()
async def test1():
await test2()
asyncio.run(test1())
You'll see:
File "C:main.py", line 24, in <module>
asyncio.run(test1())
# inner event loop stack here
File "C:main.py", line 21, in test1
await test2()
File "C:main.py", line 17, in test2
await test3()
File "C:main.py", line 13, in test3
traceback.print_stack()
Use of traceback.print_stack()
will give you the exact same traceback as thrown exception:
async def test1():
await test2()
traceback.print_stack()
# raise Exception()
await test2() # Here
await test2()
You can use traceback.extract_stack() if you want to recieve object instead of printing.
Note however that you're doing something strange. asyncio
coroutines is not supposed to be run use it's generator's nature functions like .send()
.
In asyncio
you await for coroutines and run top level coroutine using event loop. Please see how it's done in documentation.
I write another small example that shows how to print start inside inner coroutine when you use asyncio
regular way:
import asyncio
import traceback
async def test3():
traceback.print_stack()
async def test2():
await test3()
async def test1():
await test2()
asyncio.run(test1())
You'll see:
File "C:main.py", line 24, in <module>
asyncio.run(test1())
# inner event loop stack here
File "C:main.py", line 21, in test1
await test2()
File "C:main.py", line 17, in test2
await test3()
File "C:main.py", line 13, in test3
traceback.print_stack()
answered 16 hours ago
Mikhail GerasimovMikhail Gerasimov
14.6k44071
14.6k44071
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280869%2fpython-traceback-for-coroutine%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown