473,732 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threads and import

Hi,

I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:

# Sample script, simply create a new thread and run a
# regular expression match in it.
import re

import threading
class TestThread(thre ading.Thread):

def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')

tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i

# end of sample script

Now if I run this using:

$ python ThreadTest.py

then it behaves as expected, ie an output like:

start
finish
0
1
2
....

But if I run it as follows (how the inherited code was started):

$ python -c "import TestThread"

then I just get:

start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?

Thanks,
Rowan
Jun 27 '08 #1
9 2117
rs************@ googlemail.com schrieb:
Hi,

I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:

# Sample script, simply create a new thread and run a
# regular expression match in it.
import re

import threading
class TestThread(thre ading.Thread):

def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')

tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i

# end of sample script

Now if I run this using:

$ python ThreadTest.py

then it behaves as expected, ie an output like:

start
finish
0
1
2
...

But if I run it as follows (how the inherited code was started):

$ python -c "import TestThread"

then I just get:

start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.

Diez
Jun 27 '08 #2
On May 28, 8:26 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho...@ googlemail.com schrieb:
Hi,
I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:
# Sample script, simply create a new thread and run a
# regular expression match in it.
import re
import threading
class TestThread(thre ading.Thread):
def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')
tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i
# end of sample script
Now if I run this using:
$ python ThreadTest.py
then it behaves as expected, ie an output like:
start
finish
0
1
2
...
But if I run it as follows (how the inherited code was started):
$ python -c "import TestThread"
then I just get:
start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?

Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.

Diez
Strange. That is the code exactly as I run it using python 2.4.4 2.5.1
on Ubuntu 7.10. Which version of python/what platform were you using?

Rowan
Jun 27 '08 #3
rs************@ googlemail.com schrieb:
On May 28, 8:26 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
>rsoh.woodho... @googlemail.com schrieb:
>>Hi,
I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:
# Sample script, simply create a new thread and run a
# regular expression match in it.
import re
import threading
class TestThread(thre ading.Thread):
def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')
tmpThread = TestThread()
tmpThread.sta rt()
tmpThread.joi n()
import time
for i in range(10):
time.sleep(0.5)
print i
# end of sample script
Now if I run this using:
$ python ThreadTest.py
then it behaves as expected, ie an output like:
start
finish
0
1
2
...
But if I run it as follows (how the inherited code was started):
$ python -c "import TestThread"
then I just get:
start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.

Diez

Strange. That is the code exactly as I run it using python 2.4.4 2.5.1
on Ubuntu 7.10. Which version of python/what platform were you using?
mac-dir:/tmp deets$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times
>>>

But I doubt this changes anything.

Diez
Jun 27 '08 #4
On May 28, 8:52 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho...@ googlemail.com schrieb:
On May 28, 8:26 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho...@ googlemail.com schrieb:
>Hi,
I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:
# Sample script, simply create a new thread and run a
# regular expression match in it.
import re
import threading
class TestThread(thre ading.Thread):
def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')
tmpThread = TestThread()
tmpThread.star t()
tmpThread.join ()
import time
for i in range(10):
time.sleep(0.5)
print i
# end of sample script
Now if I run this using:
$ python ThreadTest.py
then it behaves as expected, ie an output like:
start
finish
0
1
2
...
But if I run it as follows (how the inherited code was started):
$ python -c "import TestThread"
then I just get:
start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.
Diez
Strange. That is the code exactly as I run it using python 2.4.4 2.5.1
on Ubuntu 7.10. Which version of python/what platform were you using?

mac-dir:/tmp deets$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times
>>>

But I doubt this changes anything.

Diez
Hmm. Just tested it again on OS X Python 2.4.4 and custom build of
Python 2.4.5 on Debian and get the same results as I had before.

Thanks,
Rowan
Jun 27 '08 #5
rs************@ googlemail.com schrieb:
On May 28, 8:52 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
>rsoh.woodho... @googlemail.com schrieb:
>>On May 28, 8:26 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho. ..@googlemail.c om schrieb:
Hi,
I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:
# Sample script, simply create a new thread and run a
# regular expression match in it.
import re
import threading
class TestThread(thre ading.Thread):
def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')
tmpThread = TestThread()
tmpThread.s tart()
tmpThread.j oin()
import time
for i in range(10):
time.sleep(0.5)
print i
# end of sample script
Now if I run this using:
$ python ThreadTest.py
then it behaves as expected, ie an output like:
start
finish
0
1
2
...
But if I run it as follows (how the inherited code was started):
$ python -c "import TestThread"
then I just get:
start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.
Diez
Strange. That is the code exactly as I run it using python 2.4.4 2.5.1
on Ubuntu 7.10. Which version of python/what platform were you using?
mac-dir:/tmp deets$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times
> >>>

But I doubt this changes anything.

Diez

Hmm. Just tested it again on OS X Python 2.4.4 and custom build of
Python 2.4.5 on Debian and get the same results as I had before.
Are you sure that ThreadTest isn't a somewhere else installed module?
youc can use python -v to check where python gets it's files.

and how about you attach/paste the full script somewhere?

Diez
Jun 27 '08 #6
On May 28, 10:24 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho...@ googlemail.com schrieb:
On May 28, 8:52 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho...@ googlemail.com schrieb:
>On May 28, 8:26 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
rsoh.woodho.. .@googlemail.co m schrieb:
Hi,
I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:
# Sample script, simply create a new thread and run a
# regular expression match in it.
import re
import threading
class TestThread(thre ading.Thread):
def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')
tmpThread = TestThread()
tmpThread.st art()
tmpThread.jo in()
import time
for i in range(10):
time.sleep(0.5)
print i
# end of sample script
Now if I run this using:
$ python ThreadTest.py
then it behaves as expected, ie an output like:
start
finish
0
1
2
...
But if I run it as follows (how the inherited code was started):
$ python -c "import TestThread"
then I just get:
start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
Works for me. And I don't see any reason why it shouldn't for you -
unless you didn't show us the actual code.
Diez
Strange. That is the code exactly as I run it using python 2.4.4 2.5.1
on Ubuntu 7.10. Which version of python/what platform were you using?
mac-dir:/tmp deets$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit <tabmultiple times
But I doubt this changes anything.
Diez
Hmm. Just tested it again on OS X Python 2.4.4 and custom build of
Python 2.4.5 on Debian and get the same results as I had before.

Are you sure that ThreadTest isn't a somewhere else installed module?
youc can use python -v to check where python gets it's files.

and how about you attach/paste the full script somewhere?

Diez
This is the full script straight from the text editor:

# START

import re

import threading
class TestThread(thre ading.Thread):

def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')

tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i

# END

In OS X I get the following output (where TestThread.py is in the
current directory):

$ python -v -c "import TestThread"
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
site.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/lib/
python2.4/site.py
import site # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/site.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
os.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/lib/
python2.4/os.py
import os # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/os.pyc
import posix # builtin
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
posixpath.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/posixpath.py
import posixpath # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/posixpath.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
stat.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/lib/
python2.4/stat.py
import stat # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/stat.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
UserDict.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/UserDict.py
import UserDict # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/UserDict.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
copy_reg.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/copy_reg.py
import copy_reg # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/copy_reg.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
types.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/types.py
import types # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/types.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
warnings.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/warnings.py
import warnings # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/warnings.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
linecache.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/linecache.py
import linecache # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/linecache.pyc
import encodings # directory /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/encodings
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
encodings/__init__.pyc matches /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/encodings/__init__.py
import encodings # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/encodings/__init__.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
codecs.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/codecs.py
import codecs # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/codecs.pyc
import _codecs # builtin
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
encodings/aliases.pyc matches /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/encodings/aliases.py
import encodings.alias es # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/encodings/aliases.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
encodings/ascii.pyc matches /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/encodings/ascii.py
import encodings.ascii # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/encodings/ascii.pyc
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
import TestThread # from TestThread.py
# wrote TestThread.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
re.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/lib/
python2.4/re.py
import re # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/re.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
sre.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/lib/
python2.4/sre.py
import sre # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/sre.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
sre_compile.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/sre_compile.py
import sre_compile # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/sre_compile.pyc
import _sre # builtin
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
sre_constants.p yc matches /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/sre_constants.p y
import sre_constants # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/sre_constants.p yc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
sre_parse.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/sre_parse.py
import sre_parse # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/sre_parse.pyc
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
threading.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/threading.py
import threading # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/threading.pyc
import thread # builtin
import time # dynamically loaded from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/lib-dynload/time.so
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
traceback.pyc matches /Library/Frameworks/Python.framewor k/Versions/
2.4/lib/python2.4/traceback.py
import traceback # precompiled from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/traceback.pyc
import collections # dynamically loaded from /Library/Frameworks/
Python.framewor k/Versions/2.4/lib/python2.4/lib-dynload/collections.so
# /Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/
atexit.pyc matches /Library/Frameworks/Python.framewor k/Versions/2.4/
lib/python2.4/atexit.py
import atexit # precompiled from /Library/Frameworks/Python.framewor k/
Versions/2.4/lib/python2.4/atexit.pyc
start
At which point it just hangs.

Thanks,
Rowan
Jun 27 '08 #7
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
import TestThread # from TestThread.py
If I use python 2.5, this doesn't happen - instead, the module ist just run.

If I use python 2.4, it doesn't work unless I do

export PYTHONPATH=.

before I use the -m-option.

But then it works as advertised...

Diez
Jun 27 '08 #8
rs************@ googlemail.com wrote:
Hi,

I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:

# Sample script, simply create a new thread and run a
# regular expression match in it.
import re

import threading
class TestThread(thre ading.Thread):

def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')

tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i

# end of sample script

Now if I run this using:

$ python ThreadTest.py

then it behaves as expected, ie an output like:

start
finish
0
1
2
...

But if I run it as follows (how the inherited code was started):

$ python -c "import TestThread"

then I just get:

start
I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
You might be interested in reading

http://groups.google.com/group/comp....f55f1475dc529f

Peter
Jun 27 '08 #9
On May 28, 1:14 pm, rsoh.woodho...@ googlemail.com wrote:
Hi,

I'm trying to work out some strange (to me) behaviour that I see when
running a python script in two different ways (I've inherited some
code that needs to be maintained and integrated with another lump of
code). The sample script is:

# Sample script, simply create a new thread and run a
# regular expression match in it.
import re

import threading
class TestThread(thre ading.Thread):

def run(self):
print('start')
try:
re.search('mmm' , 'mmmm')
except Exception, e:
print e
print('finish')

tmpThread = TestThread()
tmpThread.start ()
tmpThread.join( )
import time
for i in range(10):
time.sleep(0.5)
print i

# end of sample script

Now if I run this using:

$ python ThreadTest.py

then it behaves as expected, ie an output like:

start
finish
0
1
2
...

But if I run it as follows (how the inherited code was started):

$ python -c "import TestThread"

then I just get:

start

I know how to get around the problem but could someone with more
knowledge of how python works explain why this is the case?
For reasons I haven't figured out, child threads always acquire the
import lock. Since the main thread is already in an import, and is
waiting for the child thread to finish, this deadlocks.

"python ThreadTest.py" doesn't deadlock because ThreadTest isn't
loaded as a module - it's loaded as a script. A script doesn't hold
the import lock while it executes.

The solution is to move all the thread spawning and whatnot into a
main() function, use the "if __name__ == '__main__': main()" trick for
when you are a script, and if a module require the caller to do
ThreadTest.main () after importing.
Jun 27 '08 #10

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

Similar topics

17
2436
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next = gen.next() finally:
3
1754
by: Sebastian Meyer | last post by:
Hi Newsgroup, i have some problems with using threads and signals in one program. In my program i have three threads running, one for checking a directory at a specified interval to see if new data arrived, one waiting for work and the main thread. My problem is the following: I want to shutdown the program via a signal, so i used the signal module. I know, that signal handling mus be done by the main thread, the signal
5
1803
by: Michele Simionato | last post by:
I am getting a strange error with this script: $ cat doctest-threads.py """ >>> import time, threading >>> def example(): .... thread.out = .... while thread.running: .... time.sleep(.01) .... thread.out.append(".")
4
2492
by: J Rice | last post by:
I have been experimenting with some thread programming, but as I'm doing this on my own I am worried I might be making a major mistake. Here's a brief rundown of what I am working on. Multiple threads, via Queue, are used to perform RBL checks on an IP. The threads are passed a defined class (ConnectionScore) in their init. This is used to collect the results, including a method to add the result. If I run the program, everything...
35
4028
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? I've been leaning towards threads, I'm going to say why. Processes seem fairly expensive from my research so far. Each fork copies the entire contents of memory into the new process. There's also a more expensive context switch between...
11
3136
by: Teja | last post by:
I have an application which uses COM 's Dispatch to create a COM based object. Now I need to upgrade the application to a threaded one. But its giving an error that COM and threads wont go together. Specifically its an attribute error at the point where COM object is invoked. Any pointers please??????
6
2362
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the problem also with other imports (e.g. urllib2 etc.). And again very often in all these cases where I get weired Python exceptions, the problem is around re-functions - usually during re.compile calls during import (see some of the exceptions below). But...
5
3654
by: nimitsis | last post by:
Hello to everyone I wont to create 2 threads in Python ( thread01, thread02 ), which doing the follows : thread01, ask user to give a value to flag variable and write it to the shared memory of two threads thread02, read from shared memory and check if the flag have a specific value . The corresponding python code follows: import time import thread import threading import Numeric, sys
4
2258
by: tdahsu | last post by:
All, I'd appreciate any help. I've got a list of files in a directory, and I'd like to iterate through that list and process each one. Rather than do that serially, I was thinking I should start five threads and process five files at a time. Is this a good idea? I picked the number five at random... I was thinking that I might check the number of processors and start a multiple of that, but then I remembered KISS and it seemed that...
3
5740
by: scriptlearner | last post by:
I am trying to put up a queue (through a logging thread) so that all worker threads can ask it to log messages. However, the problem I am facing is that, well, the logging thread itself is running forever. It does not know when it should exit. Any suggestion? None of the worker threads knows for sure when the logging thread should exit since they don't know what other worker threads are doing. I also try to set a time limit for the...
0
8946
marktang
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...
1
9235
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
9181
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
8186
agi2029
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...
0
6031
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
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.