Hey folks,
Is there anyway for a signal handler in python to get the information
from a 3 argument signal handler rather than just the signal number
and stack frame?
I've got an application where I have to check for F_SETLEASE on a file
in python on Linux 2.4. What this does is tells the kernel to notify
the current process with SIGIO that a particular file descriptor is being
modified by another process. import fcntl f = open(".zshrc", "r+") fcntl.fcntl(f, fcntl.F_SETLEAS E, fcntl.F_WRLCK)
0
Now, when another process opens ".zshrc", I get a SIGIO saying
something happened. The kernel provides the information on what
descriptor changed in a siginfo_t's si_fd field.
Is there anyway to get this from python?
Thanks,
Chris
--
Chris Green <cm*@dok.org>
You now have 14 minutes to reach minimum safe distance. 11 2623
Chris Green <cm*@dok.org> writes: Hey folks,
Is there anyway for a signal handler in python to get the information from a 3 argument signal handler rather than just the signal number and stack frame?
No.
I've got an application where I have to check for F_SETLEASE on a file in python on Linux 2.4. What this does is tells the kernel to notify the current process with SIGIO that a particular file descriptor is being modified by another process.
import fcntl f = open(".zshrc", "r+") fcntl.fcntl(f, fcntl.F_SETLEAS E, fcntl.F_WRLCK)
0
Now, when another process opens ".zshrc", I get a SIGIO saying something happened. The kernel provides the information on what descriptor changed in a siginfo_t's si_fd field.
Is there anyway to get this from python?
What a wonderful interface. I think you'll have to write some C for
this...
Cheers,
mwh
--
<Erwin> I recompiled XFree 4.2 with gcc 3.2-beta-from-cvs with -O42
and -march-pentium4-800Mhz and I am sure that the MOUSE
CURSOR is moving 5 % FASTER!
-- from Twisted.Quotes
I don't know of a way to do this without an extension module. It should
be possible to do it with an extension module, though. The module
would use sigaction() to install its own handler for SIGIO, and stash
the desired fields from the siginfo_t parameter somewhere. Use
Py_AddPendingCa ll() (undocumented? but with a public API name) to run a
callback with the stashed information in the void* arg, which calls back
into Python or does whatever else you need.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFA/p61Jd01MZaTXX0R AjKJAKCXL47MW0L wZJyKcjqObHwtq1 cxYACfZgRB
0yObNIGu/VE3Bk8cwVRE/hI=
=Ye8Y
-----END PGP SIGNATURE-----
On Wed, 21 Jul 2004 12:27:57 -0400, Chris Green <cm*@dok.org> wrote: Hey folks,
Is there anyway for a signal handler in python to get the information from a 3 argument signal handler rather than just the signal number and stack frame?
I've got an application where I have to check for F_SETLEASE on a file in python on Linux 2.4. What this does is tells the kernel to notify the current process with SIGIO that a particular file descriptor is being modified by another process.
import fcntl f = open(".zshrc", "r+") fcntl.fcntl(f, fcntl.F_SETLEAS E, fcntl.F_WRLCK) 0
would this be close enough?
Python 2.3.4 (#2, Jul 5 2004, 09:15:05)
[GCC 3.3.4 (Debian 1:3.3.4-2)] on linux2
Type "help", "copyright" , "credits" or "license" for more information. import fcntl import ctypes libc = ctypes.cdll.Loa dLibrary('/lib/libc.so.6') f = open("/home/john/.bashrc") libc.fcntl(f.fi leno(), fcntl.F_SETLEAS E, fcntl.F_WRLCK)
0 # now someone cats .bashrc
.... I/O possible
--
John Lenton (jl*****@gmail. com) -- Random fortune:
bash: fortune: command not found
On Wed, 21 Jul 2004 14:03:56 -0300, John Lenton <jl*****@gmail. com> wrote: On Wed, 21 Jul 2004 12:27:57 -0400, Chris Green <cm*@dok.org> wrote: Hey folks,
Is there anyway for a signal handler in python to get the information from a 3 argument signal handler rather than just the signal number and stack frame?
I've got an application where I have to check for F_SETLEASE on a file in python on Linux 2.4. What this does is tells the kernel to notify the current process with SIGIO that a particular file descriptor is being modified by another process.
>> import fcntl >> f = open(".zshrc", "r+") >> fcntl.fcntl(f, fcntl.F_SETLEAS E, fcntl.F_WRLCK) 0
would this be close enough?
Python 2.3.4 (#2, Jul 5 2004, 09:15:05) [GCC 3.3.4 (Debian 1:3.3.4-2)] on linux2 Type "help", "copyright" , "credits" or "license" for more information. import fcntl import ctypes libc = ctypes.cdll.Loa dLibrary('/lib/libc.so.6') f = open("/home/john/.bashrc") libc.fcntl(f.fi leno(), fcntl.F_SETLEAS E, fcntl.F_WRLCK) 0 # now someone cats .bashrc
... I/O possible
sorry, I got the wrong end of the stick. But ctypes lets you do what
you want, anyways. Portable as Linux :)
--
John Lenton (jl*****@gmail. com) -- Random fortune:
bash: fortune: command not found
Hi,
I am not sure if this is the right list, but I am having a problem with
the installation of boa constructor. It all seems to have installed with
no errors, but when I try to run it, this is what I get: python /usr/lib/python2.2/boa-constructor-0.2.3/Boa.py
Starting Boa Constructor v0.2.3
importing wxPython
reading user preferences
Segmentation fault
Here is how I installed it:
I went to boa-constructor.sou rceforge.net and went to the download area.
There it says:
Before this can work, you'll need to have successfully installed
wxPython 2.4.0.7 or higher and Python 2.1 or higher. I have listed my
installed versions below.
Here is the list of my installed versions of python related things:
rpm -qa | grep -i python
python-2.2.3-5
mod_python-3.0.3-2.ent
gnome-python2-bonobo-1.99.14-5
gnome-python2-1.99.14-5
libxml2-python-2.5.10-5
bproc-python-0.9-13_Scyld
wxPythonGTK-py2.2-2.5.1.5-1
python-optik-1.4.1-2
gnome-python2-gtkhtml2-1.99.14-5
python-devel-2.2.3-5
gnome-python2-gconf-1.99.14-5
rpm-python-4.2.1-4.4
gnome-python2-canvas-1.99.14-5
Here is my list of gtk related things:
rpm -qa | grep -i gtk
gtk2-2.2.4-4.0
pygtk2-libglade-1.99.16-8
gtkhtml2-devel-2.2.0-6
pygtk2-devel-1.99.16-8
gtkhtml2-2.2.0-6
gtkam-0.1.7-6
gtkhtml3-3.0.9-4
gtk2-engines-2.2.0-2
gtk2-devel-2.2.4-4.0
gtk-doc-1.1-3.0
gtk+-1.2.10-27.1
pygtk2-1.99.16-8
gtk-engines-0.12-2.0
gtk+-devel-1.2.10-27.1
wxPythonGTK-py2.2-2.5.1.5-1
gnome-python2-gtkhtml2-1.99.14-5
gtkam-gimp-0.1.7-6
usermode-gtk-1.68-5
I downloaded boa-constructor-0.2.3.src.zip and unzipped it as root in
the /usr/lib/python2.2 directory.
Can anyone give me any suggestions on what to try next?
- Gardner
John Lenton <jl*****@gmail. com> writes: sorry, I got the wrong end of the stick. But ctypes lets you do what you want, anyways. Portable as Linux :)
Thanks for pointing me to that. Seems like a very interesting
module. It may help me out :)
--
Chris Green <cm*@dok.org>
Let not the sands of time get in your lunch.
Gardner Pomper wrote: Hi,
I am not sure if this is the right list, but I am having a problem with the installation of boa constructor. It all seems to have installed with no errors, but when I try to run it, this is what I get:
python /usr/lib/python2.2/boa-constructor-0.2.3/Boa.py
Starting Boa Constructor v0.2.3 importing wxPython reading user preferences Segmentation fault
Here is how I installed it:
I went to boa-constructor.sou rceforge.net and went to the download area. There it says:
Before this can work, you'll need to have successfully installed wxPython 2.4.0.7 or higher and Python 2.1 or higher. I have listed my installed versions below.
Here is the list of my installed versions of python related things:
rpm -qa | grep -i python python-2.2.3-5 mod_python-3.0.3-2.ent gnome-python2-bonobo-1.99.14-5 gnome-python2-1.99.14-5 libxml2-python-2.5.10-5 bproc-python-0.9-13_Scyld wxPythonGTK-py2.2-2.5.1.5-1 python-optik-1.4.1-2 gnome-python2-gtkhtml2-1.99.14-5 python-devel-2.2.3-5 gnome-python2-gconf-1.99.14-5 rpm-python-4.2.1-4.4 gnome-python2-canvas-1.99.14-5
Here is my list of gtk related things:
rpm -qa | grep -i gtk gtk2-2.2.4-4.0 pygtk2-libglade-1.99.16-8 gtkhtml2-devel-2.2.0-6 pygtk2-devel-1.99.16-8 gtkhtml2-2.2.0-6 gtkam-0.1.7-6 gtkhtml3-3.0.9-4 gtk2-engines-2.2.0-2 gtk2-devel-2.2.4-4.0 gtk-doc-1.1-3.0 gtk+-1.2.10-27.1 pygtk2-1.99.16-8 gtk-engines-0.12-2.0 gtk+-devel-1.2.10-27.1 wxPythonGTK-py2.2-2.5.1.5-1 gnome-python2-gtkhtml2-1.99.14-5 gtkam-gimp-0.1.7-6 usermode-gtk-1.68-5
I downloaded boa-constructor-0.2.3.src.zip and unzipped it as root in the /usr/lib/python2.2 directory.
Can anyone give me any suggestions on what to try next?
- Gardner
AFAIK, Boa doesn't work with wxPython 2.5.1. With Boa, you need to use
wxPython 2.4.2.
--
Vincent Wehren
Jeff Epler <je****@unpytho nic.net> writes: Use Py_AddPendingCa ll() (undocumented? but with a public API name) to run a callback with the stashed information in the void* arg, which calls back into Python or does whatever else you need.
What I ended up doing what creating a module that just installed a
handler that appends FD info onto a queue and then have a python call
that will check that queue suitable for use in an event loop.
It's my first python C extension so there's a few things I'm sure I'm
not doing right, most notably finding the spot to put finalization
code in. http://cmg.dok.org/cgi-bin/pyblosxom...hon/linuxlease
--
Chris Green <cm*@dok.org>
"I'm beginning to think that my router may be confused."
What I don't see here is any handling of threads.
The SIGIO handler might be called at the same time as Python code is
running in another thread. That means the call to getPending can see a
partially modified queue, or that the queue can be modified by a signal
while getPending is running.
Perhaps the code is written in some way that avoids these problems, but
I wasn't able to see how that would happen.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFBBRQNJd0 1MZaTXX0RAuUGAK CCe7jFNJFEXR6Bp UPMw9mJb9w5qACf dYEM
GmMXiEf+ZZ9ossz XIr6M5j0=
=FgXB
-----END PGP SIGNATURE----- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Meyer, Tony |
last post by:
(I did try to google for an answer to this, but couldn't find anything,
although plenty of instances of the warning).
I don't understand this warning:
>>> import fcntl
C:\Program Files\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL
module is deprecated; please use fcntl
DeprecationWarning)
>>>
|
by: Pierre Rouleau |
last post by:
Hi all!
I am using Python 2.3.1 on Win32 (NT, 2000).
Whenever a file imports the standard tempfile module, Python 2.3.1
issues the following warning:
C:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is
Deprecated; please use fcntl DeprecationWarning).
|
by: Ryan Grow |
last post by:
Hi,
I'm trying to use fcntl to set an existing file
descriptor to be nonblocking. This contrived example
exhibits the behavior of python that is preventing me
from doing this:
import os, fcntl, FCNTL
file = open("/tmp/testfd.txt", 'w')
|
by: Math55 |
last post by:
hi, i have this piece of code:
---
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
/* baudrate settings are defined in <asm/termbits.h>, which is
|
by: Vivek Menon |
last post by:
Hi,
I am using a C program to write/read from a serial port. The writing
part is working perfectly fine. However, I am not able to read the
values correctly and display them. To debug this issue I am also seeing
the values on minicom. Now I have used fcntl() function and then read
refp = fcntl(fd, F_SETFL, 0);
res = read(fd,buf,1024); /* Read the value sent on the serial port
buf=0; /* set end of string, so we can printf */...
| |
by: hlubenow |
last post by:
Hello,
I'd like to check, if a single key is pressed on a Linux xterm.
This code waits for a key to be pressed and returns the character:
--------------------------------------------
#!/usr/bin/env python
import sys
|
by: mhearne808[insert-at-sign-here]gmail[insert-dot-he |
last post by:
I'm having a number of problems with the fcntl module. First off, my
system info:
Mac OS X
Darwin igskcicglthearn.cr.usgs.gov 8.10.1 Darwin Kernel Version
8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386
i386 i386
Python 2.5.1 (built from source)
OK, the weirdness:
|
by: GHUM |
last post by:
hello,
in my application I am using
hSem = win32event.CreateSemaphore (None, 1,
1,"stringincludinginterfaceandport")
rt=win32event.WaitForSingleObject (hSem, 0)
if rt != win32event.WAIT_TIMEOUT:
really_do_start_my_app()
else:
|
by: The Doctor |
last post by:
Hey people,
I have two applications:
the server, which creates a server socket, waits for a real-time signal,
and if it receives one, it creates a client socket.
The client, which will connect to the server. This will generate a real-
time signal at the server, who will create a client socket for this
client.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |