Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging asyncio code in PyCharm causes absolutely crazy unrepeatable errors

In my project that based on asyncio and asyncio tcp connections that debugs with PyCharm debugger I got very and very very absurd errors.

If I put breakpoint on code after running, the breakpoint never fires. But breakpoints fires if breakpoint has been put before starting program.

But in some cases the firing on breakpoints causes strange errors (if paused on breakpoint and resumed).

The next exceptions I remarked:

  1. TypeError: 'coroutine' object not callable
  2. SystemError: unknown opcode

First exception is very rare. Can be raised in any place on code and unrepeatable. Second exception I remarked the first time recently. This is repeatable in my code. The function where I put breakpoint is function in async task (asyncio.Task). I can't repeat from scratch. But I think the type of exception (unknown opcode??? O_O) should make you think. Besides! The exception vanished if I change the code: for example I added the a = 0 line. Exception not raised after. The deleting a = 0 will return this exception again.

Is this error of kind of esoteric errors?

I think the PyCharm debugger conflicts with asnycio. Or maybe I doing something wrong?


Unknown opcode can be any line of code in the function where breakpoint put. Repeats in specific places in code. unknown opcode


This exception also can be at line, but also inside another function. Very rare and unreproducible enter image description here

like image 244
Artem Selivanov Avatar asked Nov 07 '22 17:11

Artem Selivanov


1 Answers

which version of python you use? There is new debugger for python3.6 based on inserting opcodes before starting process. You can find some more info in this repo https://github.com/Elizaveta239/frame-eval

like image 122
dyus Avatar answered Nov 14 '22 22:11

dyus