473,383 Members | 1,788 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,383 software developers and data experts.

Bug in py32win manual for file_locking for Python 2.4

Hi,

I tried to lock file in w2k using example
directly from pyWin32 manual:

#--------------
import pywintypes
ov=pywintypes.OVERLAPPED() #used to indicate starting region to lock
highbits=0xffff0000
file="c:\\\\wilma.txt"
import win32file
import win32security
import win32api
secur_att = win32security.SECURITY_ATTRIBUTES()
secur_att.Initialize()
hfile=win32file.CreateFile( file, \ .... win32con.GENERIC_READ|win32con.GENERIC_WRITE, \
.... win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE , \
.... secur_att, \
.... win32con.OPEN_ALWAYS, \
.... win32con.FILE_ATTRIBUTE_NORMAL , 0 )

win32file.LockFileEx(hfile,win32con.LOCKFILE_EXCLU SIVE_LOCK,0,highbits,ov)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
OverflowError: long int too large to convert to int
#-------------

However, using
highbits=0x7fff0000 # equals hex(sys.maxint)
gives no errors, but does locking work if
highbits are not exactly 0xffff0000?

Does anybody have example of locking the whole directory
in one go without looping thru its files?

-pekka-
Jul 18 '05 #1
1 1735
Pekka Niiranen wrote:
However, using
highbits=0x7fff0000 # equals hex(sys.maxint)
gives no errors, but does locking work if
highbits are not exactly 0xffff0000?


Try using highbits=-0x7fff0000 as your mask. That should set the MSB without
tripping over the sys.maxint limit.

Cheers,
Nick.
Jul 18 '05 #2

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

Similar topics

0
by: Bo Peng | last post by:
Dear list, I am writing a manual for my python extension using Python (2.4) latex classes. Everything seems to be fine except that the subscripts are as big as normal text ( see page 55 of...
12
by: xiong.xu.cn | last post by:
Hi there, I'm new to python and I'm from the java world. Though I love to learn python, I'm not very comfortable with the python documentation. Because when i read jdk doc, i can see the class...
1
by: adolfo | last post by:
I am at the very beginning of the DISLIN 9.3 Manual: 1.4 Quickplots Some quickplots are added to the DISLIN module which are collections of DISLIN routines for displaying data with one command....
1
by: Terry Reedy | last post by:
nishalrs wrote: Interesting new applications of Python are welcome. Googling "Python package (or module) ultrasonic sensor" did not turn up anything relevant that I saw. Start with the...
15
by: Pat | last post by:
I've been searching for a good multi-module lint checker for Python and I haven't found one yet. Pylint does a decent job at checking for errors only within a single module. Here's one of my...
0
by: Gordon Fraser | last post by:
Hi, Am Dienstag, den 07.10.2008, 15:30 +0100 schrieb Orestis Markou: That seems to work, thanks. Still trying to make sense of the manual for eval, as it says if the passed globals dict lacks...
0
by: Terry Reedy | last post by:
Liang Chen wrote: Start with the Unicode HOWTO in the HOWTOs part of the Manual set. For 2.6 http://docs.python.org/howto/unicode.html For 3.0, which has been updated in spite of the warning...
20
by: Mr.SpOOn | last post by:
Hi, I need a structure to represent a set of integers. I also need to perform on this set some basic set operations, such as adding or removing elements, joining with other sets and checking for...
5
by: Phillip B Oldham | last post by:
Will Python 3 be "stackless"? Or, rather, will it have any features similar to stackless' microthreads and channels?
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.