473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

os.ChDir() not thread-safe; was : Is tempfile.mkdtemp() thread-safe?

Gabriel Rossetti wrote:
Hello,

I'm using tempfile.mkdtemp() in a multithreading program and I've been
having problems with it. Sometimes it tells me the file I'm trying to
access (in the directory created with tempfile.mkdtemp()) doesn't
exist. I suspect that tempfile.mkdtemp() returns the same directory to
different threads sometimes. Does anyone know anything about this or
have a solution? I have to create unique and temp. directories to use
an external program that creates a temp. file with the same name every
time, thus if I want to call it from several threads, each call has to
be from a different directory.

Thank you,
Gabriel
I think I found what was wrong, I was using os.chDir(), and the current
directory is shared by all threads :

http://www.biais.org/blog/index.php/...ds-and-oschdir
http://bugs.python.org/issue1367

I hope this helps anyone that ever has such a problem!

Gabriel
Aug 29 '08 #1
0 1071

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

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, We're using the ISAPI version of PHP with IIS5.0 On some websites for some reason any php file in the websites root is given the path winnt/system32 (getcwd() returns...
5
by: Nicholas Geraldi | last post by:
I have a script that uses the chdir() function. I know the script works ( works perfectly on my host ), but when I put the script on my server here at work I get the following error. Warning:...
0
by: Jon Schull | last post by:
I find that cgitb fails to show error context if I've changed my default directory, so I tried to subclass cgitb and get it to save the directory we were in when the program started. Didn't work. ...
4
by: Yun Mao | last post by:
Hi, How to make changes to os.environ and os.path.chdir still effective after I run the script? Currently, the changes are only good within my script. I would like the shell who called python...
0
by: Tom McDavid | last post by:
I'm trying to learn more Python and have come across a strange behavior. I have Python2.3 installed on a Win2K machine. If I start the python command line, I can do the following: Python 2.3.2...
11
by: Chris | last post by:
Hi, For info I am using VS 2005 beta 2 I have a Console App and I want it to do the equivalent of a Change Directory (CD) command that you would do in normal command line mode as follows: ...
3
by: dannycolligan | last post by:
I have a strange problem with os.chdir... here is my script that I am using to edit the filenames of my music library: #!/usr/bin/python from os import * ...
5
by: HMS Surprise | last post by:
Tried executing os.chdir("c:\twill") from a python Tk shell and got the error message: WindowsError: The filename, directory name, or volume label syntax is incorrect: 'c:\twill'. I have the...
0
by: Julien Biezemans | last post by:
Hi everyone, I've written a file:// scheme stream wrapper that acts like chroot() (but is more flexible, does not require root privileges and works on any platform). Everything works just fine...
4
by: rdoneil | last post by:
I am in unix and in my perl program, I am trying to move back to the directory the program was originally started in. Obviously, at somepoint in my program it has to move to another directory, and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.