Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysterious failure under Windows #45414

Closed
akineko mannequin opened this issue Aug 31, 2007 · 6 comments
Closed

Mysterious failure under Windows #45414

akineko mannequin opened this issue Aug 31, 2007 · 6 comments

Comments

@akineko
Copy link
Mannequin

akineko mannequin commented Aug 31, 2007

BPO 1073
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-09-01.05:34:55.606>
created_at = <Date 2007-08-31.19:01:38.803>
labels = []
title = 'Mysterious failure under Windows'
updated_at = <Date 2007-09-01.05:34:55.584>
user = 'https://bugs.python.org/akineko'

bugs.python.org fields:

activity = <Date 2007-09-01.05:34:55.584>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2007-09-01.05:34:55.606>
closer = 'loewis'
components = []
creation = <Date 2007-08-31.19:01:38.803>
creator = 'akineko'
dependencies = []
files = []
hgrepos = []
issue_num = 1073
keywords = []
message_count = 6.0
messages = ['55537', '55542', '55543', '55544', '55545', '55550']
nosy_count = 3.0
nosy_names = ['loewis', 'ggenellina', 'akineko']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1073'
versions = ['Python 2.5']

@akineko
Copy link
Mannequin Author

akineko mannequin commented Aug 31, 2007

Hi,

I'm not sure this is a right place to write in the problem I found.
What I found was:
(1) create a thread
(2) open a file in the thread
(3) everything works fine under Solaris
(4) Openning a file in the thread fails intermittenly under Windows
Not always it fails.
The file is there but it returns:
File "h:\prj\socgear\unidbg\tkunidbg\sub.py", line 94, in thread_worker
fd = open(fn, 'rb')
IOError: [Errno 2] No such file or directory: './XXX.dat'
(5) The problem goes away (under Windows) if I have the main thread wait
until the file is opened using Event.

//

The program also uses Tkinter but I'm not sure that is relevant.
I cannot submit the whole program as it is too big to submit.

Aki-

@loewis
Copy link
Mannequin

loewis mannequin commented Aug 31, 2007

I don't see the problem. When open() reports that the file does not
exist, the most likely reason is that it really does not exist. Perhaps
it has not been created, yet, and you need to wait until it has been
created before you can open it?

@akineko
Copy link
Mannequin Author

akineko mannequin commented Aug 31, 2007

I know it is hard to believe.
I spent days to try out many things.

For example, I added the following:
try:
print os.path.isfile(fn) <<<---

                fd = open(fn, 'rb')
                crypted = fd.read()
                fd.close()
                idx = crypted.index('\n')
            except (IOError, OSError, ValueError,):
                raise

When I run, I got following cases randomly:
(1) True, Open successfully
(2) True, Open failed
(3) False, Open failed
(4) False, Open successfully

The file is a binary data file and is already sitting in the directory
before the execution of the program.

I know that for other people it is very difficult to work on such case.
But this is something to do with threading under windows.

Aki-

@ggenellina
Copy link
Mannequin

ggenellina mannequin commented Sep 1, 2007

Does the file exist before program is started, and remains after
program finishes?
If it is your program which creates the file, you may have a race
condition. Maybe some delays/retries will be enough, or perhaps you
will have to use some other syncronization mechanisms.

Also, I see you use a relative path. Do you change the current
directory (with os.chdir or similar)?

@akineko
Copy link
Mannequin Author

akineko mannequin commented Sep 1, 2007

Sorry to disappoint you but ...
(1) Does the file exist before program is started, and remains after
program finishes?
Yes and Yes
(2) Do you change the current directory (with os.chdir or similar)?
No. The file is in the current directory where the program was invoked.

//

Probably, only way to settle this is to create a small test case.
But I'm not sure if that is easy.
(For example, this problem won't occur if no activity in the main thread.)

Aki-

@loewis
Copy link
Mannequin

loewis mannequin commented Sep 1, 2007

I'm closing this as "works for me" now. It cannot possibly be a bug in
Python, since the error was created by the operating system; Python does
not make it up randomly. I also doubt that the operating system will
arbitrarily report that a file is not present if the calling process
uses threads.

So if you can come up with a reproducible test case, please submit a new
bug report. Otherwise, you are on your own figuring out what's going on.

@loewis loewis mannequin closed this as completed Sep 1, 2007
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants