RE: DorothyLocker and performance

"Garth T Kidd" <garth-OnzZ1s1DREKDegMON/[email protected]> Wed, 29 Sep 2004 06:29:20 +1000
Newsgroups gmane.comp.pythin.pyds.devel
Organization Deadly Bloody Serious
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------=_NextPart_000_002F_01C4A5ED.A91A93E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

cvs diff -c PyDS\DorothyLocker.py > 20040928-2222-dorothyagain.diff

I've updated, backed out the conflict damage (CVS deciding to replace =
whole
sections of identical code when only __revision__ had changed), and
re-generated. Attached.=20

I'm beginning to like unit tests. It was quite reassuring to run the =
module
under 2.2 and see a line of dots followed by OK. I'd otherwise have =
spent a
lot of time stressing that I had some *other* 2.2 compatibility issues
somewhere. I can't run PyDS up wholesale under 2.2 because all my third
party libraries are loaded for 2.3...=20

-----Original Message-----
From: pyds-dev-admin-iYtK5bfT9M//Ad8WF/[email protected]
[mailto:pyds-dev-admin-iYtK5bfT9M//Ad8WF/[email protected]] On Behalf Of Bauer, Georg
Sent: Wednesday, 29 September 2004 1:02 AM
To: 'Garth T Kidd'; 'Thomas Klaeger'
Cc: 'PyDS Developer List (E-Mail)'
Subject: AW: [Pyds-dev] DorothyLocker and performance

Hi!

Sorry, but that's not a patch against the current CVS. That patch can't =
be
merged because it contains stuff that was already applied or something =
like
that:

bash-2.05a$ patch --dry-run -p0 <20040928-2222-dorothyagain.diff =
patching
file PyDS/DorothyLocker.py Reversed (or previously applied) patch =
detected!
Assume -R? [n] n Apply anyway? [n] y Hunk #1 FAILED at 1.
Hunk #2 FAILED at 37.
2 out of 2 hunks FAILED -- saving rejects to file =
PyDS/DorothyLocker.py.rej
bash-2.05a$ patch --dry-run -p0 <20040928-2222-dorothyagain.diff =
patching
file PyDS/DorothyLocker.py Reversed (or previously applied) patch =
detected!
Assume -R? [n] y Hunk #2 FAILED at 21.
1 out of 2 hunks FAILED -- saving rejects to file =
PyDS/DorothyLocker.py.rej

bye, Georg

-----Urspr=FCngliche Nachricht-----
Von: Garth T Kidd [mailto:garth-OnzZ1s1DREKDegMON/[email protected]]
Gesendet: Dienstag, 28. September 2004 14:23
An: 'Bauer, Georg'; 'Thomas Klaeger'
Cc: 'PyDS Developer List (E-Mail)'
Betreff: RE: [Pyds-dev] DorothyLocker and performance


That's a weird one.=20

Oh, hang on.

E.E..E.........E.E....E

Yep. Python 2.2 works differently to Python 2.3. Here's a fix.=20

-----Original Message-----
From: pyds-dev-admin-iYtK5bfT9M//Ad8WF/[email protected]
[mailto:pyds-dev-admin-iYtK5bfT9M//Ad8WF/[email protected]] On Behalf Of Bauer, Georg
Sent: Tuesday, 28 September 2004 5:24 PM
To: 'Garth T Kidd'; Bauer, Georg; 'Thomas Klaeger'
Cc: PyDS Developer List (E-Mail)
Subject: AW: [Pyds-dev] DorothyLocker and performance

Hi!

>Oh, did I forget to send that one in? Sorry. :| I had that, alternative =

>logging for those post-shutdown logs, and code to make sure EventsTool=20
>was last.

Your patch wasn't able to be applied - I wrote you this directly and
off-list :-)

My solution is a bit more flexible, though: you now have a flag to tell
where to sort the tool on shutdown. I use that to move the =
PreferencesTool
directly before EventsTool so that the preferences can be still fetched
until the very last moment in shutdown.

>You're calling PyDS.Tool.getToolsForShutdown twice, just like you used=20
>to getTools. Is there anything wrong with saving the value and using it
twice?


Changed that, although it really doesn't matter much - the shutdown is =
only
called once in a running instance ;-)

>Could you drop in this latest version of DorothyLocker? You're now a=20
>fair way behind, and I've lost track of when I fixed certain bugs. That =

>might

Did that. But it would really be a bit better if you stick to CVS =
mechanisms
- just do an update and merge in the changes I commited and then =
reproduce
your patch with regard to current CVS. It's much more likely that I put =
in a
working patch than full module sources, as the latter would require me =
to
make the diff myself to see what changed. And I am known to be lazy ;-)

For example this time: after adding the full module I could'nt start =
PyDS,
because of some changes to the interface of DorothyLocker that required
additional patches. But your patch didn't work, as your full module =
already
was installed. Mixing different patch/dist methods allways makes things =
more
complicated.

Oh, and now the CVS is broken. One thing was a small typo in Tool.py =
(wrong
indention) that was easily fixed. But now it barfs about "sequence must =
be
integer" on start. What's that? It happens in your __getitem__ method in
your FramingContext where it accesses the framestack (line 103). Looks =
like
ltrim_common doesn't produce integers as index somehow (maybe pos not
initialized?). This happens directly at startup of PyDS:

Exception exceptions.TypeError: sequence index must be integer
('/opt/pyds/lib/python2.2/site-packages/PyDS/Tool.py', 1407, '_release',
'return self.lock.release()')
('/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py', 359,
'release', "self.__sanity_check('release', my_context)")
('/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py', 260,
'__sanity_check', 'lock_uniques, my_uniques =3D =
ltrim_common(lock_context,
my_context)')
('/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py', 54,
'ltrim_common', 'return oblist1[pos:], oblist2[pos:]')
('/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py', 103,
'__getitem__', 'return self.framestack[index]') Traceback (most recent =
call
last):
   File "/opt/pyds/bin/pyds-start", line 51, in ?
     PyDS.Server.start_server(daemon=3D_PyDS.daemon)
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/Server.py", line =
298, in
start_server
     PyDS.Tool.initTools(PyDS.Tool.mainstatus)
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/Tool.py", line 317, =
in
initTools
     tool._initdb()
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/WeblogTool.py", line =
77,
in _initdb
     finally: self._release()
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/Tool.py", line 1407, =
in
_release
     return self.lock.release()
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py",
line 359, in release
     self.__sanity_check('release', my_context)
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py",
line 260, in __sanity_check
     lock_uniques, my_uniques =3D ltrim_common(lock_context, my_context)
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py",
line 54, in ltrim_common
     return oblist1[pos:], oblist2[pos:]
   File "/opt/pyds/lib/python2.2/site-packages/PyDS/DorothyLocker.py",
line 103, in __getitem__
     return self.framestack[index]
TypeError: sequence index must be integer


>also be behind some of the performance hits you're seeing (I used the=20
>latest, assuming you'd incorporated it after that submission I made=20
>that
got
>blocked for size).

I usually write about what I commited (and at least it's in the CVS RSS
feed). So if you don't see me mentioning it, it supposedly isn't in CVS. =
I
either wasn't able to apply it (then I usually write something) or I =
just
plain missed it.

bye, Georg


_______________________________________________
Pyds-dev mailing list
Pyds-dev-iYtK5bfT9M//Ad8WF/[email protected]
http://www.westfalen.de/cgi-bin/mailman/listinfo/pyds-dev


_______________________________________________
Pyds-dev mailing list
Pyds-dev-iYtK5bfT9M//Ad8WF/[email protected]
http://www.westfalen.de/cgi-bin/mailman/listinfo/pyds-dev

------=_NextPart_000_002F_01C4A5ED.A91A93E0
Content-Type: application/octet-stream;
	name="20040928-2222-dorothyagain.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="20040928-2222-dorothyagain.diff"

Index: PyDS/DorothyLocker.py
===================================================================
RCS file: /pyds/PyDS/PyDS/DorothyLocker.py,v
retrieving revision 1.6
diff -c -c -r1.6 DorothyLocker.py
*** PyDS/DorothyLocker.py	28 Sep 2004 07:02:25 -0000	1.6
--- PyDS/DorothyLocker.py	28 Sep 2004 20:25:09 -0000
***************
*** 98,103 ****
--- 98,107 ----
          finally: 
              del frame # apparently helpful with frame objects
      
+     def __getslice__(self, i, j): 
+         "Get a slice of frames from the context."
+         return self.framestack.__getslice__(i, j)
+ 
      def __getitem__(self, index): 
          "Get a frame from the context by number (-1 is most recent)."
          return self.framestack[index]
***************
*** 212,218 ****
              setattr(cls, att, True)
      squawk = classmethod(squawk)
          
!     def __init__(self, verbose=None, name='(unknown)', ignores=None):
          "Initialise the DorothyRLock."
          _Verbose.__init__(self, verbose)
          self.name = name
--- 216,222 ----
              setattr(cls, att, True)
      squawk = classmethod(squawk)
          
!     def __init__(self, verbose=None, name='(unknown)', ignores=None): 
          "Initialise the DorothyRLock."
          _Verbose.__init__(self, verbose)
          self.name = name
***************
*** 574,585 ****
              context = self.one()
              minitrace = context.minitrace()
              assert isinstance(minitrace, list)
              for filename, lineno, name in minitrace: 
!                 assert isinstance(filename, basestring)
                  assert isinstance(lineno, int)
!                 assert isinstance(name, basestring)
              assert minitrace[0][2] == 'three'
!             assert minitrace[0][0] == __file__
              
          def test_formatted_minitrace(self): 
              "Formatted context mini-trace"
--- 578,596 ----
              context = self.one()
              minitrace = context.minitrace()
              assert isinstance(minitrace, list)
+             if hasattr(__builtins__, 'basestring'): 
+                 stringtype = basestring
+             else: 
+                 stringtype = str
              for filename, lineno, name in minitrace: 
!                 assert isinstance(filename, stringtype)
                  assert isinstance(lineno, int)
!                 assert isinstance(name, stringtype)
              assert minitrace[0][2] == 'three'
!             try: 
!                 assert minitrace[0][0] == __file__
!             except NameError: 
!                 pass # Python 2.2
              
          def test_formatted_minitrace(self): 
              "Formatted context mini-trace"

------=_NextPart_000_002F_01C4A5ED.A91A93E0--