Skip to content

Commit

Permalink
Merge pull request OfflineIMAP#171 from sudipm-mukherjee/sudip/fcntl
Browse files Browse the repository at this point in the history
Import fcntl
  • Loading branch information
thekix authored Dec 18, 2023
2 parents 77e70ed + 365a1eb commit d29a4dc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions offlineimap/imaplibutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
from imaplib2 import IMAP4, IMAP4_SSL, InternalDate

try:
import portalocker
import fcntl
except:
try:
import fcntl
except:
pass # Ok if this fails, we can do without.
pass # Ok if this fails, we can do without.


class UsefulIMAPMixIn:
Expand Down Expand Up @@ -147,11 +144,14 @@ def open(self, host, port):
def set_nonblocking(self, fd):
"""Mark fd as nonblocking"""

# get the file's current flag settings
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
# clear non-blocking mode from flags
fl = fl & ~os.O_NONBLOCK
fcntl.fcntl(fd, fcntl.F_SETFL, fl)
try:
# get the file's current flag settings
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
# clear non-blocking mode from flags
fl = fl & ~os.O_NONBLOCK
fcntl.fcntl(fd, fcntl.F_SETFL, fl)
except NameError:
pass # fnctl not available. :(

def read(self, size):
"""data = read(size)
Expand Down

0 comments on commit d29a4dc

Please sign in to comment.