|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Select( ) Vs Thread( )
What would you rather use? cause right now im using select to run a while loop in gui program.. and every things runs smothly.. but.. i always get people asking.. "Why are you using select?" or "Why are you using thread" and i want to know what the users here think, as i feel better getting an answer here ( my home ) then any other place, i read about select.. and read a bit about thread and.. i think that select is a good way to go
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#2
|
|||
|
|||
|
Using threads will add extra complexity to your script. You will have to think about race conditions and the way in which you're going to share data in between threads.
|
|
#3
|
||||
|
||||
|
Got to remember that adding threads to a Python program to try speeding it up, does not always work. Reason: Python has a Global Interpreter Lock (GIL) that is set every time you try to access a python object and only the thread that holds the lock can access the object. In order for other threads to get some access to the GIL, the interpreter releases the lock every sys.setcheckinterval bytecodes (default = 10 bytecoee instructions) or if the thread blocks for an I/O operation. This way, another thread can acquire the lock and continue.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month |
|
#4
|
|||
|
|||
|
It depends what your program is doing.
If you are reading from a socket then select is a viable solution - look at the asyncore library for a high level wrapper to it. However using select on files and pipes will only work on UNIX systems, so will not be portable to Windows. This may or may not be a problem for you. There will probably be times when you want concurrent processing that does not do IO at all, then select will be useless and you will have to use threads. Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Select( ) Vs Thread( ) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|