2

Okay now I'm working on simple flask app and it is working but while working I needed ipdb at certain api, after I added it

    Traceback (most recent call last):
  File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
.
.
.

  File "/usr/local/lib/python3.6/bdb.py", line 51, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/local/lib/python3.6/bdb.py", line 69, in dispatch_line
    self.user_line(frame)
  File "/usr/local/lib/python3.6/pdb.py", line 261, in user_line
    self.interaction(frame, None)
  File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/IPython/core/debugger.py", line 294, in interaction
    OldPdb.interaction(self, frame, traceback)
  File "/usr/local/lib/python3.6/pdb.py", line 352, in interaction
    self._cmdloop()
  File "/usr/local/lib/python3.6/pdb.py", line 321, in _cmdloop
    self.cmdloop()
  File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/IPython/terminal/debugger.py", line 97, in cmdloop
    line = self.pt_app.prompt() # reset_current_buffer=True)
  File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py", line 986, in prompt
    return self.app.run()
  File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 788, in run
    return get_event_loop().run_until_complete(self.run_async(pre_run=pre_run))
  File "/usr/local/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/usr/local/lib/python3.6/asyncio/events.py", line 602, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-1'.

After that I added threading snippet like that at the flask file

    from threading import Thread
    t = Thread(target=app, args=())
    t.daemon = True
    t.start()

    t.join()
    if __name__ == '__main__':
        app.run()

but it raises

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
TypeError: __call__() missing 2 required positional arguments: 'environ' and 'start_response'

I tried both debug and non debug mode

A.Raouf
  • 2,171
  • 1
  • 24
  • 36
  • Do you really need to wrap the Flask app in a Thread? – Kent Shikama Dec 11 '19 at 06:40
  • I'm not sure, I did that to make the thread working with the ipdb – A.Raouf Dec 11 '19 at 06:59
  • 4
    I've been experiencing this exact issue as well, and I've never encountered it before so it seems like a recent issue. I looked at recent releases of the `ipdb` library and ipython is one of it's dependencies. I downgraded `ipython` to an older version (7.0.0, specifically) and now my debugger is working. Try explicitly downgrading ipython (`pip install ipython==7.0.0` for example). – Brodan Dec 16 '19 at 19:44

0 Answers0