<s> """<STR_LIT>""" <EOL> import struct <EOL> import fcntl <EOL> import os , sys <EOL> from test . test_support import verbose , TESTFN <EOL> filename = TESTFN <EOL> try : <EOL> os . O_LARGEFILE <EOL> except AttributeError : <EOL> start_len = "<STR_LIT>" <EOL> else : <EOL> start_len = "<STR_LIT>" <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> start_len = "<STR_LIT>" <EOL> if sys . platform in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if struct . calcsize ( '<STR_LIT:l>' ) == <NUM_LIT:8> : <EOL> off_t = '<STR_LIT:l>' <EOL> pid_t = '<STR_LIT:i>' <EOL> else : <EOL> off_t = '<STR_LIT>' <EOL> pid_t = '<STR_LIT:l>' <EOL> lockdata = struct . pack ( off_t + off_t + pid_t + '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , fcntl . F_WRLCK , <NUM_LIT:0> ) <EOL> elif sys . platform in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> lockdata = struct . pack ( '<STR_LIT>' , fcntl . F_WRLCK , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> elif sys . platform in [ '<STR_LIT>' ] : <EOL> lockdata = None <EOL> else : <EOL> lockdata = struct . pack ( '<STR_LIT>' + start_len + '<STR_LIT>' , fcntl . F_WRLCK , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if lockdata : <EOL> if verbose : <EOL> print '<STR_LIT>' , repr ( lockdata ) <EOL> f = open ( filename , '<STR_LIT:w>' ) <EOL> rv = fcntl . fcntl ( f . fileno ( ) , fcntl . F_SETFL , os . O_NONBLOCK ) <EOL> if verbose : <EOL> print '<STR_LIT>' , rv <EOL> if sys . platform not in [ '<STR_LIT>' ] : <EOL> rv = fcntl . fcntl ( f . fileno ( ) , fcntl . F_SETLKW , lockdata ) <EOL> if verbose : <EOL> print '<STR_LIT>' , repr ( rv ) <EOL> f . close ( ) <EOL> os . unlink ( filename ) <EOL> f = open ( filename , '<STR_LIT:w>' ) <EOL> rv = fcntl . fcntl ( f , fcntl . F_SETFL , os . O_NONBLOCK ) <EOL> if sys . platform not in [ '<STR_LIT>' ] : <EOL> rv = fcntl . fcntl ( f , fcntl . F_SETLKW , lockdata ) <EOL> f . close ( ) <EOL> os . unlink ( filename ) </s>
