Title: missing module fcntl
Type: behaviour Severity: normal
Components: Any Versions: Jython 2.7
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: amak, fwierzbicki, stefan.richthofer, wbrana, zyasoft
Priority: low Keywords:

Created on 2012-07-01.10:30:37 by wbrana, last changed 2018-03-07.19:14:17 by jeff.allen.

msg7297 (view) Author: (wbrana) Date: 2012-07-01.10:30:36
Jython 2.7.0a2+ (default:e4afcd777d1b+, Jul 1 2012, 12:22:26) 
[Java HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_33
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named fcntl
inst@local /mnt/md3/cache/inst/jython2 $ python
Python 2.7.3 (default, May  5 2012, 10:54:18) 
[GCC 4.4.7] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl
>>> dir(fcntl)
msg7517 (view) Author: Alan Kennedy (amak) Date: 2012-11-07.22:39:05
35.10. fcntl — The fcntl() and ioctl() system calls

Platforms: Unix

This module performs file control and I/O control on file descriptors. It is an interface to the fcntl() and ioctl() Unix routines.

DO you expect that this should work on jython on non-Unix platforms?

Should it work on Windows? It doesn't on cpython.

What do you want to use the fcntl module for?
msg7713 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-20.00:18:21
I don't think this one makes sense for us, closing.
msg10484 (view) Author: Jim Baker (zyasoft) Date: 2015-11-17.16:35:29
Let's reopen this. It's still a low priority, but it should be eminently doable for 2.7.2, given that JNR already supports this functionality:

Through the ugliness that is PosixModule#getFD, we already support int file descriptors where possible (at least for files that are not sockets), so this would be a straightforward addition.
msg10485 (view) Author: Jim Baker (zyasoft) Date: 2015-11-17.16:41:08
A real test of how far we can push fcntl will be working with os.pipe descriptors, as seen with

(FWIW, this is motivated by attempting to run the Tornado test suite, which is further motivated by the Tornado benchmark that Jython does not yet run, see Brett Cannon's notebook on Python performance,
msg10670 (view) Author: Jim Baker (zyasoft) Date: 2016-01-26.21:20:57
Also used in the package youtube-dl for file locking support:

    import fcntl

    def _lock_file(f, exclusive):
        fcntl.flock(f, fcntl.LOCK_EX if exclusive else fcntl.LOCK_SH)

    def _unlock_file(f):
        fcntl.flock(f, fcntl.LOCK_UN)

This specific functionality is implementable with, which is likely to be portable than JNR for this particular support (based on previous experience - use JNR only when nothing else is available in Java).
msg10886 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2016-08-01.03:53:07
Note that fcntl is workable with JyNI, at least to some extend on Linux (didn't try on OSX yet). I did not test in detail, but I know that it is sufficiently supported to allow numpy-import to succeed. I didn't investigate what numpy actually does with fcntl, but if I let JyNI log imported modules, it lists fcntl when importing numpy.
Date User Action Args
2018-03-07 19:14:17jeff.allensetmilestone: Jython 2.7.2 ->
2016-08-01 03:53:09stefan.richthofersetnosy: + stefan.richthofer
messages: + msg10886
2016-01-26 21:20:58zyasoftsetmessages: + msg10670
2015-11-17 16:41:09zyasoftsetmessages: + msg10485
2015-11-17 16:35:30zyasoftsetstatus: closed -> open
nosy: + zyasoft
messages: + msg10484
assignee: fwierzbicki ->
milestone: Jython 2.7.2
resolution: wont fix -> accepted
2013-02-20 00:18:31fwierzbickisetstatus: open -> closed
versions: + Jython 2.7, - 2.7a2
2013-02-20 00:18:21fwierzbickisetpriority: low
assignee: fwierzbicki
resolution: wont fix
messages: + msg7713
nosy: + fwierzbicki
2012-11-07 22:39:06amaksetmessages: + msg7517
2012-08-28 22:22:05amaksetnosy: + amak
2012-07-01 10:30:37wbranacreate