|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
File lock issueHi
there,
I have a problem
with an xml file locking after read and/or write.
I have a short
sample code with unit test attached. Below are the outputs from Jython and
CPython (v 2.5.4). Is this a bug?
Can anybody offer an
alternative workaround?
I am using Jython
2.5.1 on Windows XP and java version "1.6.0_16".
Cheers,
Gareth
>jython
lock.py
E ====================================================================== ERROR: runTest (__main__.TestDelete) ---------------------------------------------------------------------- Traceback (most recent call last): File "W:\testTeam\SIT\JySit\sit\scripts\lock.py", line 73, in tearDown os.remove(self.fileName) File "C:\jython2.5.1\Lib\os.py", line 342, in remove raise OSError(0, "couldn't delete file", path) OSError: [Errno 0] couldn't delete file: 'C:\\testdir\\test.xml' ----------------------------------------------------------------------
Ran 1 test in 0.454s FAILED (errors=1)
>python
lock.py
. ---------------------------------------------------------------------- Ran 1 test in 0.015s OK
------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueI know there is an issue with file locks being retained after files are closed on Windows:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 And I think the features that trigger this bug are used in Jython. The symptoms described here are exactly the ones I've seen with this issue before. I know a guy with excellent knowledge in this area, I'll get back when I've consulted him on how this can be worked around on the insides of Jython. Until then your best bet is to use a better operating system. cheers, Tobias On Mon, Sep 28, 2009 at 4:53 PM, DOUTCH GARETH-GDO003 <Gareth.Doutch@...> wrote:
------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueOk, I've discussed this with my colleague, and the only solution is to not use memory mapped IO on Windows. Performance of regular IO buffers on Windows is (according to his benchmarks) even slightly better than the memory mapped ones on Windows (oddly enough).
The next step on this issue is to look at the IO code in Jython (this is not a part of Jython I've been involved with that much) to verify that this actually is the problem, and then modify it so that Jython doesn't use memory mapped IO on Windows. I don't have the time to look deeper into this at the moment, so if someone else on the dev team has some time over to take a look at this, that would be great. Cheers, Tobias
On Mon, Sep 28, 2009 at 8:16 PM, Tobias Ivarsson <thobes@...> wrote: I know there is an issue with file locks being retained after files are closed on Windows: ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueOn Sep 28, 2009, at 1:29 PM, Tobias Ivarsson wrote: > Ok, I've discussed this with my colleague, and the only solution is > to not use memory mapped IO on Windows. Performance of regular IO > buffers on Windows is (according to his benchmarks) even slightly > better than the memory mapped ones on Windows (oddly enough). > > The next step on this issue is to look at the IO code in Jython > (this is not a part of Jython I've been involved with that much) to > verify that this actually is the problem, and then modify it so that > Jython doesn't use memory mapped IO on Windows. We don't do use mmapped IO. I think this is just ElementTree.parse assuming CPython ref counting and not closing its file handles, combined with the fact that Windows disallows removal of a file when it's in use. Gareth, could you please log a ticket for this on the bug tracker? > > I don't have the time to look deeper into this at the moment, so if > someone else on the dev team has some time over to take a look at > this, that would be great. > > Cheers, > Tobias > > On Mon, Sep 28, 2009 at 8:16 PM, Tobias Ivarsson <thobes@...> > wrote: > I know there is an issue with file locks being retained after files > are closed on Windows: > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 > > And I think the features that trigger this bug are used in Jython. > The symptoms described here are exactly the ones I've seen with this > issue before. > > I know a guy with excellent knowledge in this area, I'll get back > when I've consulted him on how this can be worked around on the > insides of Jython. Until then your best bet is to use a better > operating system. > > cheers, > Tobias > > On Mon, Sep 28, 2009 at 4:53 PM, DOUTCH GARETH-GDO003 <Gareth.Doutch@... > > wrote: > Hi there, > > I have a problem with an xml file locking after read and/or write. > > I have a short sample code with unit test attached. Below are the > outputs from Jython and CPython (v 2.5.4). Is this a bug? > Can anybody offer an alternative workaround? > > I am using Jython 2.5.1 on Windows XP and java version "1.6.0_16". > > Cheers, > > Gareth > > > >jython lock.py > E > ====================================================================== > ERROR: runTest (__main__.TestDelete) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "W:\testTeam\SIT\JySit\sit\scripts\lock.py", line 73, in > tearDown > os.remove(self.fileName) > File "C:\jython2.5.1\Lib\os.py", line 342, in remove > raise OSError(0, "couldn't delete file", path) > OSError: [Errno 0] couldn't delete file: 'C:\\testdir\\test.xml' > > ---------------------------------------------------------------------- > Ran 1 test in 0.454s > > FAILED (errors=1) > > > >python lock.py > . > ---------------------------------------------------------------------- > Ran 1 test in 0.015s > > OK > -- Philip Jenvey ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueOn Mon, Sep 28, 2009 at 11:31 PM, Philip Jenvey <pjenvey@...> wrote:
We don't do use mmapped IO. I think this is just ElementTree.parse assuming CPython ref counting and not closing its file handles, combined with the fact that Windows disallows removal of a file when it's in use. Ah, yes. That's an even simpler explanation. I assumed that the libraries were playing nicely and only looked at the opening/closing of files in the attached file. And since these were all ok, I remembered having sworn over the mmapped IO issue on Windows numerous times before, with this being a classic example of the symptoms. At least now we know what workarounds would be needed for Windows if we ever decide to start using mmapped IO :-) Thanks Philip. - Tobias ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueHi there,
I've logged a ticket. http://bugs.jython.org/issue1479 Is there any kind of workaround? Do I need to patch the elementtree module? This issue is blocking my migration to 2.5 from 2.2. Cheers, Gareth -----Original Message----- From: Philip Jenvey [mailto:pjenvey@...] Sent: 28 September 2009 22:32 To: Tobias Ivarsson Cc: DOUTCH GARETH-GDO003; jython-users@... Subject: Re: [Jython-users] File lock issue On Sep 28, 2009, at 1:29 PM, Tobias Ivarsson wrote: > Ok, I've discussed this with my colleague, and the only solution is to > not use memory mapped IO on Windows. Performance of regular IO buffers > on Windows is (according to his benchmarks) even slightly better than > the memory mapped ones on Windows (oddly enough). > > The next step on this issue is to look at the IO code in Jython (this > is not a part of Jython I've been involved with that much) to verify > that this actually is the problem, and then modify it so that Jython > doesn't use memory mapped IO on Windows. We don't do use mmapped IO. I think this is jt ElementTree.parse assuming CPython ref counting and not closing its file handles, combined with the fact that Windows disallows removal of a file when it's in use. Gareth, could you please log a ticket for this on the bug tracker? > > I don't have the time to look deeper into this at the moment, so if > someone else on the dev team has some time over to take a look at > this, that would be great. > > Cheers, > Tobias > > On Mon, Sep 28, 2009 at 8:16 PM, Tobias Ivarsson <thobes@...> > wrote: > I know there is an issue with file locks being retained after files > are closed on Windows: > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 > > And I think the features that trigger this bug are used in Jython. > The symptoms described here are exactly the ones I've seen with this > issue before. > > I know a guy with excellent knowledge in this area, I'll get back when > I've consulted him on how this can be worked around on the insides of > Jython. Until then your best bet is to use a better operating system. > > cheers, > Tobias > > On Mon, Sep 28, 2009 at 4:53 PM, DOUTCH GARETH-GDO003 > <Gareth.Doutch@... > > wrote: > Hi there, > > I have a problem with an xml file locking after read and/or write. > > I have a short sample code with unit test attached. Below are the > outputs from Jython and CPython (v 2.5.4). Is this a bug? > Can anybody offer an alternative workaround? > > I am using Jython 2.5.1 on Windows XP and java version "1.6.0_16". > > Cheers, > > Gareth > > > >jython lock.py > E > ====================================================================== > ERROR: runTest (__main__.TestDelete) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "W:\testTeam\SIT\JySit\sit\scripts\lock.py", line 73, in > tearDown > os.remove(self.fileName) > File "C:\jython2.5.1\Lib\os.py", line 342, in remove > raise OSError(0, "couldn't delete file", path) > OSError: [Errno 0] couldn't delete file: 'C:\\testdir\\test.xml' > > ---------------------------------------------------------------------- > Ran 1 test in 0.454s > > FAILED (errors=1) > > > >python lock.py > . > ---------------------------------------------------------------------- > Ran 1 test in 0.015s > > OK > -- Philip Jenvey ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: File lock issueOK I've answered my own question. Modifying Lib\xml\etree\ElementTree.py
like so seems to cure the issue: @line 577: def parse(self, source, parser=None): try: if not hasattr(source, "read"): source = open(source, "rb") if not parser: parser = XMLTreeBuilder() while 1: data = source.read(32768) if not data: break parser.feed(data) self._root = parser.close() return self._root finally: if hasattr(source, "read"): source.close() Thanks for the pointers! Cheers, Gareth -----Original Message----- From: DOUTCH GARETH-GDO003 Sent: 29 September 2009 09:33 To: jython-users@... Subject: Re: [Jython-users] File lock issue Hi there, I've logged a ticket. http://bugs.jython.org/issue1479 Is there any kind of workaround? Do I need to patch the elementtree module? This issue is blocking my migration to 2.5 from 2.2. Cheers, Gareth -----Original Message----- From: Philip Jenvey [mailto:pjenvey@...] Sent: 28 September 2009 22:32 To: Tobias Ivarsson Cc: DOUTCH GARETH-GDO003; jython-users@... Subject: Re: [Jython-users] File lock issue On Sep 28, 2009, at 1:29 PM, Tobias Ivarsson wrote: > Ok, I've discussed this with my colleague, and the only solution is to > not use memory mapped IO on Windows. Performance of regular IO buffers > on Windows is (according to his benchmarks) even slightly better than > the memory mapped ones on Windows (oddly enough). > > The next step on this issue is to look at the IO code in Jython (this > is not a part of Jython I've been involved with that much) to verify > that this actually is the problem, and then modify it so that Jython > doesn't use memory mapped IO on Windows. We don't do use mmapped IO. I think this is jt ElementTree.parse assuming CPython ref counting and not closing its file handles, combined with the fact that Windows disallows removal of a file when it's in use. Gareth, could you please log a ticket for this on the bug tracker? > > I don't have the time to look deeper into this at the moment, so if > someone else on the dev team has some time over to take a look at > this, that would be great. > > Cheers, > Tobias > > On Mon, Sep 28, 2009 at 8:16 PM, Tobias Ivarsson <thobes@...> > wrote: > I know there is an issue with file locks being retained after files > are closed on Windows: > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154 > > And I think the features that trigger this bug are used in Jython. > The symptoms described here are exactly the ones I've seen with this > issue before. > > I know a guy with excellent knowledge in this area, I'll get back when > I've consulted him on how this can be worked around on the insides of > Jython. Until then your best bet is to use a better operating system. > > cheers, > Tobias > > On Mon, Sep 28, 2009 at 4:53 PM, DOUTCH GARETH-GDO003 > <Gareth.Doutch@... > > wrote: > Hi there, > > I have a problem with an xml file locking after read and/or write. > > I have a short sample code with unit test attached. Below are the > outputs from Jython and CPython (v 2.5.4). Is this a bug? > Can anybody offer an alternative workaround? > > I am using Jython 2.5.1 on Windows XP and java version "1.6.0_16". > > Cheers, > > Gareth > > > >jython lock.py > E > ====================================================================== > ERROR: runTest (__main__.TestDelete) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "W:\testTeam\SIT\JySit\sit\scripts\lock.py", line 73, in > tearDown > os.remove(self.fileName) > File "C:\jython2.5.1\Lib\os.py", line 342, in remove > raise OSError(0, "couldn't delete file", path) > OSError: [Errno 0] couldn't delete file: 'C:\\testdir\\test.xml' > > ---------------------------------------------------------------------- > Ran 1 test in 0.454s > > FAILED (errors=1) > > > >python lock.py > . > ---------------------------------------------------------------------- > Ran 1 test in 0.015s > > OK > -- Philip Jenvey ------------------------------------------------------------------------ ------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
|
|
|
|
|
|
Re: File lock issueI forgot to mention that I had no problem using this module
in Jython 2.2.1
Gareth From: DOUTCH GARETH-GDO003 Sent: 30 September 2009 12:03 To: jython-users@... Subject: Re: [Jython-users] File lock issue In which case should I then add:
try
...
finally:
file.close()
In all places a file is opened?
Before I suggest it as a bug fix?
Cheers,
Gareth
From: Sébastien Boisgérault [mailto:Sebastien.Boisgerault@...] Sent: 29 September 2009 17:57 To: DOUTCH GARETH-GDO003 Cc: jython-users@... Subject: Re: [Jython-users] File lock issue Gareth, Could you also file a bug and suggest the bug fix to CPython ? So far Jython used the CPython ElementTree.py file, it would be nice to continue this way. Cheers, SB DOUTCH GARETH-GDO003 a écrit :
------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
| Free embeddable forum powered by Nabble | Forum Help |