4

It seems simply importing ipdb when making an http request wrapped in a multiprocessing Process instance causes the program to exit with no errors or messages.

The following script behaves very strangely:

from multiprocessing import Process
import requests
import ipdb

def spawn():

    print("before")
    r = requests.get("http://wtfismyip.com")
    print("after")

Process(target=spawn).start()

If you run this in terminal the output is simply before and you are back at your prompt. If you comment out import ipdb everything is fine and the request is successfully made.

  • Storing the Process instance in a variable and calling join() after start() didn't make a difference.
  • This happens in both Python 2.7.10 and 3.5.0.
  • It does not happen with the traditional pdb.
  • Other people here and here have also had this issue. In the former I am not sure if importing ipdb was the cause. In the latter it appeared to be an package/python version upgrade issue, but I checked that my iPython and ipdb are the current latest (4.0.0 and 0.8.1).

Can anyone explain why this is happening?

Community
  • 1
  • 1
kilgoretrout
  • 3,547
  • 5
  • 31
  • 46
  • I could not recreate this with Python 2.7.9 and IPython 2.3.0 on Linux. What OS are you on? – skrrgwasme Nov 24 '15 at 00:02
  • OS X Yosemite 10.10.5. Note that I saw this on 2.7.10 and 3.5.0, maybe something changed in 2.7.9 -> 2.7.10 that is causing this. No clue. I'm using iPython 4.0.0. – kilgoretrout Nov 24 '15 at 01:24
  • I cannot explain, but you could find a workaround by only importing ipdb when you actually need it: `import ipdb; ipdb.set_trace()`. Keeping debug-related statements in the same place will make things easier when you'll need to remove them before pushing to production (if you ever do) – Romain G Nov 24 '15 at 14:58
  • Thanks or your comment, I get that. I'd like to understand why, or help raise attention to a bug if there is one in one of the packages. – kilgoretrout Nov 24 '15 at 15:00
  • @ministry I am facing something similar in Python 2.7.12 / ipdb 0.11 on Ubuntu 16.04.4 as well. Not sure what is causing this. Have you figured out the reason for this? Please let me know. – Phani Jun 18 '18 at 17:35
  • @Phani no sorry, I have not looked at this for a while. – kilgoretrout Jun 18 '18 at 22:00

0 Answers0