Pdb error while debug python app with serverless launched offline

I have problem with debugging my view function with
import pdb; pdb.set_trace()
placed inside it and serverless launched as
> sls offline start
in console.
Namely, making correspondent GET request I receive the following error:

Python: > /.../handler.py(88)get_results()
-> request_params = event.query_params

Python: (Pdb)

Python: 2019-02-20 18:37:43,648 [ERROR] | ...
Traceback (most recent call last):
  File ".../handler.py", line 88, in get_results
  File "/usr/lib/python3.6/bdb.py", line 51, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/lib/python3.6/bdb.py", line 70, in dispatch_line
    if self.quitting: raise BdbQuit

Google suggests that the problem is in the inability of serverless process to read from stdin, but I don’t know how to handle this problem.

Any suggestions?

I found a solution on stackoveflow:

  1. create two fifos:

    mkfifo fifo_stdin
    mkfifo fifo_stdout

in one terminal

  1. In the same terminal open stdout on background, and write to stdin:

    cat fifo_stdout & cat > fifo_stdin

  2. In python code create the the pdb object, and use it:

    import pdb
    mypdb = pdb.Pdb(stdin=open(‘fifo_stdin’, ‘r’), stdout=open(‘fifo_stdout’, ‘w’))


  3. Run python script from the folder where fifos were placed (or place fifos in the first step in the folder with python code) in another terminal

Now I am able to use pdb in first console!

It is useful to use --noTimeout option while debugging: sls offline --noTimeout