File descriptor access in scripting module

Running Ignition 8.1.31 on a Windows machine.

Is there an idiomatic Jython way, or perhaps some way with Java to interact with the file descriptor value (an integer) returned by os.open? The return value appears to be some sort of wrapper class and I'm not sure of how to drill down to the actual integer value. Here's a sample from my REPL showing to reproduce the object I'm struggling with:

>>> import os
>>> fd = os.open("exercise.c", os.O_RDWR)
>>> isinstance(fd, int)
False

Nerd-sniped me.

I put this in a script console:

import os
f = os.open('/home/philip/.screenrc', os.O_RDWR)
print type(f)
fd = f.getFD()
print type(fd)

It yields:

<type 'org.python.core.io.FileIO'>
<type 'java.io.FileDescriptor'>

So, not an integer.

The first of those is here:

The second is an internal java type with no exposed way to get the numeric fd.

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/FileDescriptor.html

Sorry.

What you actually trying to do?

2 Likes

A file descriptor priority queue. Just a POC, nothing dedicated to. The current project we have a database table with integer priority column and it works fine. Thank you for poking around :slight_smile: