how to handle pydevd.settrace() with python when forking a process

I have a question about how pydevd.settrace() works.

I am working with a python application that forks a process to handle incoming requests. This raises a question. At the beginning of the execution, in order to debug with pydev, the following are called: import pydevd; pydevd.settrace(‘<network address>’). I assume this sets up a network connection between the process being debugged and the debug server. Now, this application is listening on another socket (let’s use linux/unix in this example) and when a request arrives, it forks a process to handle that request. What is desired is for the debugging to now involve two different independent processes – the original process and the forked process. However, (at least in unix-like OSes) both the parent and child processes share the same socket, so if a breakpoint is set for code in the parent there is no way to distinguish this from setting a breakpoint for code in the child. In other words, if the breakpoint is reached, there is no way to tell if the parent or child process triggered the breakpoint.

If the socket created by the settrace call were available, when the child process executes, it could close it and then issue a new import pydevd; pydevd.settrace call. This would separate the debugging of the parent and child But, I see no way to do that with pydevd functions (at least there is nothing in the documentation I have found on the web). Is there a way to “close” a settrace() session in order to start another?

New contributor

dnessett is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

The PyDev debugger should usually attach to all subprocesses automatically and create a new debugger session (so, what you’re saying about closing a session and then starting a new one shouldn’t be needed as multiple sessions can happen in parallel over the same socket server from the Eclipse side).

You may want to see whether the related setting is properly set in your installation just to make sure.

There is a caveat when using Remote Debugging though:

If you’re using pydevd.settrace you need to ask it to do that though by passing patch_multiprocessing=True.

i.e.:

pydevd.settrace(host='192.168.0.1', patch_multiprocessing=True)

Another option could be just calling pydevd.settrace(...) multiple times from multiple processes — after starting the remote debugger, any new pydevd.settrace(...) call should automatically attach to the debugger and create a new independent debug session — just make sure you haven’t stopped the remote debugger session (i.e.: in this case as in the regular case, multiple sessions can happen in parallel over the same socket server from the Eclipse side).

If the remote scenario is common for you, maybe you can leave the remote debugger always on…

6

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật