Ticket #93 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

Python application blocks in sys.stdin.readline() because C module running on different thread is calling a blocking OS function

Reported by: bennylp Owned by: bennylp
Priority: blocker Milestone: release-0.5.10
Component: applications Version: 0.5.9
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description

On Linux (or at least my Linux), pjsua_app.py application will block forever on sys.stdin.readline(), and somehow this is related to the other thread calling py_pjsua.handle_events() (if this is commented, the keyboard input will function properly).

Change History

comment:1 Changed 12 years ago by bennylp

  • Priority changed from normal to blocker

comment:2 Changed 12 years ago by bennylp

  • Status changed from new to closed
  • Resolution set to fixed
  • Summary changed from Python application blocks in sys.stdin.readline() to Python application blocks in sys.stdin.readline() because C module running on different thread is calling a blocking OS function

Fixed in r945.

It turns out that when a C module needs to call a blocking function call, it really should wrap the blocking call with Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS macros.

This article provides some information on this: http://www.python.org/doc/current/api/threads.html

Note: See TracTickets for help on using tickets.