Issue1074

classification
Title: support for "signal" and "fcntl" module
Type: rfe Severity: normal
Components: Core Versions: 2.5b0
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: cheeming, glyph, mboersma, mcella, pjenvey, thijs, zyasoft
Priority: normal Keywords:

Created on 2008-07-16.18:08:20 by cheeming, last changed 2009-03-12.07:50:49 by zyasoft.

Messages
msg3339 (view) Author: Chew Chee Ming (cheeming) Date: 2008-07-16.18:08:19
I tried out jython with a project from work and we use the signal
module. We also use twisted quite a bit and twisted also uses signal
module. And also the "fcntl" module but that is just a pretty small part.
msg3341 (view) Author: Philip Jenvey (pjenvey) Date: 2008-07-17.01:36:24
This is really two different bugs

Chris McClimans had started creating a signal module a few months ago 
while trying to port IPython to jython. Java doesn't expose any official 
API for dealing with signals, but there's actually some undocumented 
facilities for it in sun.misc. He pastebin'd what he had so far here:

http://pylonshq.com/pasties/646

and a test for it here:

http://pylonshq.com/pasties/647

fcntl could be implemented via JNA. It would also require Python files 
to return their real file descriptor via fileno() -- currently it 
returns a fake file descriptor, because Java doesn't allow access to the 
real one (which is in a private field in java.io.FileDescriptor). We 
could 'steal' it via reflection, though -- which is what JRuby does
msg3344 (view) Author: Chew Chee Ming (cheeming) Date: 2008-07-17.12:32:27
Thanks for the info about the signal module.

For the code in http://pylonshq.com/pasties/646

I tried using it in Jython@r4960 and I found that it doesn't support
signal EMT and INFO. I am using java version 1.5.0_14.
msg3476 (view) Author: Glyph Lefkowitz (glyph) Date: 2008-09-06.16:40:38
Twisted definitely needs this to function: see also issue1122.
msg3519 (view) Author: Jim Baker (zyasoft) Date: 2008-09-13.18:28:30
Twisted has a patch for signal that we're evaluating for ipython and
twisted:
http://twistedmatrix.com/trac/attachment/ticket/3413/signal.py

There's no EMT signal in that patch. Digging on this a bit, EMT is an
AIX-specific signal. Cheeming, is there anything required here other
than uncommenting it out in the patch? 
http://www.ibm.com/developerworks/java/library/i-signalhandling/
msg3551 (view) Author: Glyph Lefkowitz (glyph) Date: 2008-09-13.23:15:41
INFO and EMT are commented out because the original signal module (which
I stole from pylons' pastebin) raised an exception when trying to define
those signals.

A better signal module would loop over the list of signals and catch the
exception.
msg3552 (view) Author: Jim Baker (zyasoft) Date: 2008-09-13.23:18:42
Matt Boersma is working on a version of signals.py that does the right
thing in terms of working across windows, etc., so that ipython will
work. So that will fix the issue with EMT, etc.
msg3945 (view) Author: Michele Cella (mcella) Date: 2008-12-17.14:44:43
CherryPy also needs the signal module to work right.

cherrypy$ grep signal *
_cpengine.py:import signal

Another annoying thing that should be solved by a working signal module
(at least "sabi" told me so in IRC) is that jython doesn't raise the
KeyboardInterruptException, this is generally used not only by CherryPy.
msg3976 (view) Author: Jim Baker (zyasoft) Date: 2008-12-29.08:02:50
Initial support for signal based on Glyph's patch is committed in r5805,
not without controversy; see
http://pylonshq.com/irclogs/%23jython/%23jython.2008-12-28.log.html

Note this also included os.kill, os.wait, os.waitpid.

sun.misc.Signal obviously has portability concerns. It might be possible
to do this jna-posix. For the moment, JRuby in SunSignalFacade.java has
chosen to use sun.misc.Signal, so that's an interesting data point.
msg4233 (view) Author: Jim Baker (zyasoft) Date: 2009-03-12.07:50:49
Closing out, I don't see fcntl support as likely for Jython. Please
submit any enhancements for signal in a separate RFE ticket, it seems as
complete as sun.misc.Signal will accommodate.
History
Date User Action Args
2009-03-12 07:50:49zyasoftsetstatus: open -> closed
versions: + 2.5b0, - 2.5alpha1
type: rfe
messages: + msg4233
priority: normal
assignee: zyasoft
resolution: fixed
2009-01-19 02:00:46thijssetnosy: + thijs
2008-12-29 08:02:53zyasoftsetmessages: + msg3976
2008-12-17 14:44:43mcellasetnosy: + mcella
messages: + msg3945
2008-09-13 23:18:43zyasoftsetmessages: + msg3552
2008-09-13 23:15:41glyphsetmessages: + msg3551
2008-09-13 18:28:30zyasoftsetnosy: + zyasoft, mboersma
messages: + msg3519
2008-09-06 16:40:38glyphsetnosy: + glyph
messages: + msg3476
2008-07-17 12:32:27cheemingsetmessages: + msg3344
2008-07-17 01:36:27pjenveysetnosy: + pjenvey
messages: + msg3341
2008-07-16 18:08:20cheemingcreate