473,890 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

threading problem

hi all

my program terminates with error i dont know why it tells 'TypeError:
run() takes exactly 1 argument (10 given)'

=program======= =============
import os, os.path, threading, sys

def get_all_files(p ath):
"""return all files of folder path, scan with subfolders
"""
if len(path) > 0:
if path[-1] == ':':
path=path+'\\'
try:
for i in os.listdir(path ):
j = os.path.join(pa th, i)
if os.path.isdir(j ):
for ii in get_all_files(j ):
yield ii
if os.path.isfile( j):
yield j
except:pass

#----------------

lock1 = threading.Lock( )

def run(path):
for i in get_all_files(p ath):
lock1.acquire()
print i
lock1.release()

#----------------

for path in os.listdir('c:\ \'):
if os.path.isdir(o s.path.join('c: \\', path)):
threading.Threa d(target = run, args = (os.path.join(' c:\\',
path))).start()
else:
lock1.acquire()
print path
lock1.release()
=============== =============


=output======== =============
=============== =============== == RESTART
=============== =============== ==
AUTOEXEC.BAT
boot.iniExcepti on in thread Thread-1:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (10 given)
Bootfont.bin
BOOTLOG.PRV
BOOTLOG.TXT
BOOTSECT.DOS
COMMAND.COM
CONFIG.SYS
DETLOG.TXT
devicetable.log
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (25 given)

FRUNLOG.TXT
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (9 given)

hsf5442.sys
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (10 given)

IO.SYS
LOGO.SYS
MSDOS.---
MSDOS.SYS
netldx.vxd
NETLOG.TXT
NHL2005.mdf
NHL2005.mds
ntdetect.com
ntldr
Exception in thread Thread-5:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (9 given)

PAGEFILE.SYS
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (16 given)

Exception in thread Thread-7:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (11 given)

Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (11 given)

Exception in thread Thread-9:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (11 given)

rew.ini
Exception in thread Thread-10:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (10 given)

SETUPLOG.TXT
SUHDLOG.DAT
Exception in thread Thread-11:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (28 given)

SYSTEM.1ST
Exception in thread Thread-12:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (7 given)

Exception in thread Thread-13:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (7 given)

Exception in thread Thread-14:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (10 given)

Exception in thread Thread-15:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (8 given)

~WRD0003.tmp
Exception in thread Thread-16:
Traceback (most recent call last):
File "C:\Python23\li b\threading.py" , line 436, in __bootstrap
self.run()
File "C:\Python23\li b\threading.py" , line 416, in run
self.__target(* self.__args, **self.__kwargs )
TypeError: run() takes exactly 1 argument (16 given)

=============== =============
Jul 18 '05 #1
2 2997
Egor Bolonev wrote:
hi all

my program terminates with error i dont know why it tells 'TypeError:
run() takes exactly 1 argument (10 given)' [snip] threading.Threa d(target = run, args = (os.path.join(' c:\\',
path))).start()


I believe the args argument to threading.Threa d is supposed to be a
sequence.
import os
path = 'directory'
os.path.join('c :\\', path) 'c:\\directory' (os.path.join(' c:\\', path)) 'c:\\directory' (os.path.join(' c:\\', path),) ('c:\\directory ',)

I think if you change the call to look like:

threading.Threa d(target=run, args=(os.path.j oin('c:\\', path),)).start( )

or

threading.Threa d(target=run, args=[os.path.join('c :\\', path)]).start()

then you should be okay. You're probably getting the 10 argument
message because your string is 10 characters long and threading.Threa d
is treating each character in your string as an argument:
def f(arg): .... print arg
.... def g(func, args): .... func(*args)
.... g(f, 'abcdefghij')

Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
File "<interacti ve input>", line 2, in g
TypeError: f() takes exactly 1 argument (10 given)

Steve
Jul 18 '05 #2
On Fri, 10 Dec 2004 00:12:16 GMT, Steven Bethard
<st************ @gmail.com> wrote:
I think if you change the call to look like:

threading.Threa d(target=run, args=(os.path.j oin('c:\\', path),)).start( )


oh i see now. thanks
s='sdgdfgdfg'
s == (s) True s == (s,) False

Jul 18 '05 #3

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

Similar topics

65
6782
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
19
6502
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread interrupt is a very primitive functionality for stopping a blocked thread.
17
2454
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:
77
5400
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for the moment. I'd be *very* grateful if people with any interest in multi-threading would read it (even just bits of it - it's somewhat long to go through the whole thing!) to check for accuracy, effectiveness of examples, etc. Feel free to mail...
11
5058
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found that the UDP communication is my biggest drain on performance! Communication where the client and the server are on the same machine still takes 300ms or sometimes much more per packet on an Athlon64 3000+ running Linux (Fedora Core 5 x64). I must...
17
6455
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. Note, the Windows task manager shows 2 CPUs on the Performance tab with hyper-threading is turned on. Both Python 2.3.5 and 2.4.3 (downloaded from python.org) have this problem. The operating system is MS Windows XP Professional.
9
1870
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying
5
6941
by: CCLeasing | last post by:
For an application I'm creating I want to create a 'fake' progress bar. By fake I mean a progress bar that looks like it's doing something but actually isn't. I know philosophically this isn't sound. But my little app is a 'fake' app and is designed to look like another - hence this seeming crazy situation of needing to fake a progess bar. PROBLEM.
126
6786
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard: http://www.cse.wustl.edu/~schmidt/ACE.html the same way that the STL (and subsequently BOOST) have been subsumed? Since it already runs on zillions of platforms, they have obviously worked most of the kinks out of the generalized threading and processes idea (along with many...
0
9976
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...
0
11215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10908
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,...
1
8008
isladogs
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...
0
7160
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
5835
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
6035
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4665
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
3
3267
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.