This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: BlockingIOError not raised inside function.
Type: behavior Stage: resolved
Components: IO Versions: Python 3.4
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, ned.deily, pcunningham80@gmail.com, r.david.murray
Priority: normal Keywords:

Created on 2016-05-14 02:03 by pcunningham80@gmail.com, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg265501 - (view) Author: padraic cunningham (pcunningham80@gmail.com) Date: 2016-05-14 02:03
When the following code snippets are run from two separate shells, the code inside the function does not raise any error on the second call while the second snippet successfully raises a BlockingIOError on the second run: 


# No error raised.
def func():
    lockfile = open('lockfile', 'w')
    fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
    input() # no error raised, can be sleep etc..


func()

# Error raised.
lockfile = open('lockfile', 'w')
fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
input() # no error raised
msg265502 - (view) Author: padraic cunningham (pcunningham80@gmail.com) Date: 2016-05-14 02:07
When the following code snippets are run from two separate shells, the code inside the function does not raise any error on the second call while the second snippet successfully raises a BlockingIOError on the second run: 


# No error raised.
def func():
    lockfile = open('lockfile', 'w')
    fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
    input() # no error raised, can be sleep etc..


func()

# Error raised.
lockfile = open('lockfile', 'w')
fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
input()
msg265503 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-05-14 02:09
What platform are you running this on and can you give a more detailed procedure for reproducing the problem you see?
msg265619 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-05-15 15:12
If I copy the second code, and add an import for fcntl, and run the resulting program twice from two different shells, I get a BlockingIOError. This is on linux.
msg407853 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-06 18:18
On a Mac I get the "BlockingIOError: [Errno 35] Resource temporarily unavailable" with both version (with and without the function).
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71203
2021-12-07 08:45:13iritkatrielsetstatus: pending -> closed
resolution: works for me
stage: resolved
2021-12-06 18:18:28iritkatrielsetstatus: open -> pending
nosy: + iritkatriel
messages: + msg407853

2016-05-15 15:12:20r.david.murraysetnosy: + r.david.murray
messages: + msg265619
2016-05-14 02:09:16ned.deilysetnosy: + ned.deily
messages: + msg265503
2016-05-14 02:07:24pcunningham80@gmail.comsetmessages: + msg265502
2016-05-14 02:03:39pcunningham80@gmail.comcreate