473,624 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

threading.Event file descriptor

Hi,
Is there any way to get the file descriptor on Unix or handle on Windows
associated internally with a threading.Event object? So that it can be
used in a call to select or WaitForMultiple Objects.
Thx and regards,
Nicolas
Jul 18 '05 #1
4 2070

Nicolas Fleury wrote:
Hi,
Is there any way to get the file descriptor on Unix or handle on Windows associated internally with a threading.Event object? So that it can be used in a call to select or WaitForMultiple Objects.
Thx and regards,
Nicolas


Good idea! But...

There is no event handle used in Event object (for NT at least). Do not
know about Linux...

Unless you want to rewrite the interpreter (namelly
PyThread_alloca te_lock.c) for platforms you are talking about, you
would be better of, if you create your own class (derived from Event,
and ovewritte aquire, release and wait methods).

Jul 18 '05 #2
el*******@gmail .com wrote:
There is no event handle used in Event object (for NT at least). Do not
know about Linux...
And there's no handle at all? It's not important if it's not an event
handle as long as it is an handle usable with WaitForMultiple Objects.

Also, I don't understand how it will be possible to implement
threading.Event without using finally, at the lower level, a handle,
since as far as I know this is the mechanisms the OS offers.
Unless you want to rewrite the interpreter (namelly
PyThread_alloca te_lock.c) for platforms you are talking about, you
would be better of, if you create your own class (derived from Event,
and ovewritte aquire, release and wait methods).


I wouldn't want to derive from Event since my goal would be to submit a
patch to make subprocess.Pope n.wait take an optional threading.Event to
kill the process.

Regards,
Nicolas
Jul 18 '05 #3
//And there's no handle at all?

There is one (check thread_nt.h) you have to "propagate" HANDLE to
Pythom level. That's why, you have to change the interpreter. Do not
forget, that thread is a build-in module.

//I wouldn't want to derive from Event since my goal would be to submit
a
patch to make subprocess.Pope n.wait take an optional threading.Event to
kill the process.

And that's it? Right now aquire_lock is non-interruptable, as a result
your Popen.wait is also non-interruptable, but if you pass derived
event you will be able to handle more generic cases.

Jul 18 '05 #4
el*******@gmail .com wrote:
//And there's no handle at all?

There is one (check thread_nt.h) you have to "propagate" HANDLE to
Pythom level. That's why, you have to change the interpreter. Do not
forget, that thread is a build-in module.
Sounds fine with me. A fileno (or whatever) function can be added to
threading.Event on all platforms, giving access to internal file
descriptor/handle.
//I wouldn't want to derive from Event since my goal would be to submit
a
patch to make subprocess.Pope n.wait take an optional threading.Event to
kill the process.

And that's it? Right now aquire_lock is non-interruptable, as a result
your Popen.wait is also non-interruptable, but if you pass derived
event you will be able to handle more generic cases.


I'm not 100% sure I understand what you say. Support killing the
process with any handle, not only an event, would be a good thing. But
it doesn't change the fact that, IMHO, the usefulness of threading.Event
is just too limited if it doesn't support select or
WaitForMultiple Objects. I think also that threading.Threa d should give
access to its internal handle (at least thread module does).

Regards,
Nicolas
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
16207
by: Kevin | last post by:
Has anyone else run into random IOErrors ( bad file descriptor) in multi-threaded Python apps? I've searched the newsgroups, and the only references I can find to that seem to be sporadically related to threading, but nobody seems to have a "fix" or even a clear understanding of what the issue is. The app I'm running into this with (once in a while... not really repeatable predictably) is using 3 threads, and I'm using locks around all...
8
4202
by: Graeme Matthew | last post by:
Hi all I just cannot seem to find any documentation that shows an example of using the factory method Event() in threads. I have a thread pool and if there are no jobs in a Queue I want them to wait for something to be inserted. When a job is inserted I want to send an Event, the first thread that picks it up runs with the job the rest wait for another insert Event. I have been looking at some C, c++ implementations and some use a...
13
2707
by: Varun | last post by:
Hi Friends, Department of Information Technology, Madras Institute of Technology, Anna University, India is conducting a technical symposium, Samhita. As a part of samhita, an Online Programming Contest is scheduled on Sunday, 27 Feb 2005. This is the first Online Programming Contest in India to support Python !!!!. Other languages supported are C and C++.
6
6270
by: pembed2003 | last post by:
Hi all, Given something like: std::ofstream out_file("path"); how do I extract the file descriptor from out_file? Is it possible? What I want is to extract the file descriptor and then pass it to flock like: flock(???, LOCK_EX);
2
5037
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
3
2539
by: Chris Dunaway | last post by:
Consider the following simple classes/interfaces defined below. When the derived class raises the events, on which thread is the event code run? Do I need to do anything to catch the events in my main app? What threading issues do I have if several of these fileproc classes are instantiated and run at the same time? '*** BEGIN CODE Public Interface IFileProc ReadOnly Property FileMask() As String Function Process(ByVal filename As...
2
1415
by: hecklar | last post by:
This is my first time posting here, so i apologize if i'm posting in the wrong subgroup or whatever, but here goes... I’m having a problem with threading and events (permissions?) in a VB.net Windows application (background service). I’m trying to write an application that processes files, launching a new thread for each file that is dropped into a certain folder. Now, the application works like a charm on my Win2000 machine, but...
1
3204
by: hg | last post by:
Hi, I have two classes, one listens and accepts connections, gets the socket, reads the first byte from the opened socket then launches a thread (threading) and gives it the socket identifier. The first time the thread attempts to read from the given socket, socket.py raises a bad file descriptor in _dummy. I tried using plain threads with the same problem.
0
1582
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first version i made, the gui would freeze after clicking the close button until pygame finished playing the sound. In Windows it was acceptable because it could be ignored easily, but in
0
8614
jinu1996
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...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
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...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
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
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.