emesene forum
November 22, 2008, 03:50:32 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: PROBLEMS WITH 1.0.x? TAKE A LOOK IN HERE - FATAL ERRORS? (1.0.x) REPORT THEM HERE
 
  Home   Forum   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: gobject fun!  (Read 528 times)
dx
h4x0r
Administrator
Hero Member
*****

l33tness: 16
Offline Offline

Posts: 544


<insert stuff>

dx@dxzone.com.ar
View Profile WWW Email
« on: January 08, 2008, 09:37:35 PM »

Some snips from my diff:

Code:
+        self.connect('destroy', setattr, self.controller, 'addBuddy', None)
Silly one. I learnt this with the one-line version of eval (before the multiline version replaced it, i had some fun with setattr, __import__, and/or to chain expressions, etc)


Code:
+            def safeADL(chunk, next):
+                self.socket.sendPayloadCommand( "ADL", '', chunk )
+                gobject.timeout_add(1000, gobject.idle_add, safeADL, \
+                    next.pop(0), next)
+
+            ADLChunks = self.contactManager.getADL()
+            safeADL(ADLChunks.pop(0), ADLChunks)
I thought "ok, i have to implement yet another «delayed idle priority loop over glib», and i'll have to write a function that does the actual work and then a function that calls idle_add to call that function after a timeout, and then have the first function to call the second one with a timeout but don't forget to call the second one initially blah blah".

Then realised that it sucks, and wrote the snippet above.

Code:
+            gobject.idle_add(self.emit, 'initial-status-change', command, tid, params)
This one is simpler, of course. Remember that when a idle source is run, the next source runs after the mainloop is idle. So if you add lots of idle sources when the mainloop is busy, when it's idle again you see CPU at 100% for a few seconds, but GUI is almost completely responsive.

Logger connects itself to initial-status-change. Did I mention that a slow callback function connected to a signal makes the emit() call slower? And that those emit() work over the mainloop of course. And makes the mainloop unresponsive for an extra (time_to_add_a_contact_event * amount_of_contacts) seconds? Here it reached 2 minutes i think. And, yes, we have to reply a CHL message quickly, otherwise the server disconnects us.
Logged

asd
JoinTheHell
Global Moderator
Hero Member
*****

l33tness: 16
Offline Offline

Posts: 736



View Profile WWW
« Reply #1 on: January 09, 2008, 08:31:47 AM »

I guess that's the new --safe arg (svn log -r 1003 ftw)
if yes (and I don't blame myself now because of not understanding 100% of what you said) - it doesn't work for me.
I always get:
Quote
Error during login, please retry
(pop from empty list)

I even tried with empty cache.


debug:
Quote
Traceback (most recent call last):
  File "/home/luis/Projekte/emesene/Controller.py", line 1095, in login
    msn.login()
  File "/home/luis/Projekte/emesene/emesenelib/core.py", line 403, in login
    safeADL(ADLChunks.pop(0), ADLChunks)
  File "/home/luis/Projekte/emesene/emesenelib/core.py", line 400, in safeADL
    next.pop(0), next)
IndexError: pop from empty list
pop from empty list
Logged
dx
h4x0r
Administrator
Hero Member
*****

l33tness: 16
Offline Offline

Posts: 544


<insert stuff>

dx@dxzone.com.ar
View Profile WWW Email
« Reply #2 on: January 09, 2008, 01:39:39 PM »

Because i'm stupid.

Code:
Index: emesenelib/core.py
===================================================================
--- emesenelib/core.py  (revisión: 1004)
+++ emesenelib/core.py  (copia de trabajo)
@@ -396,11 +396,13 @@
         else:
             def safeADL(chunk, next):
                 self.socket.sendPayloadCommand( "ADL", '', chunk )
-                gobject.timeout_add(1000, gobject.idle_add, safeADL, \
-                    next.pop(0), next)
+                if next:
+                    gobject.timeout_add(1000, gobject.idle_add, safeADL, \
+                        next.pop(0), next)
 
             ADLChunks = self.contactManager.getADL()
-            safeADL(ADLChunks.pop(0), ADLChunks)
+            if ADLChunks:
+                safeADL(ADLChunks.pop(0), ADLChunks)
         
         # change the personal message
         self.changePersonalMessage('')
Logged

asd
JoinTheHell
Global Moderator
Hero Member
*****

l33tness: 16
Offline Offline

Posts: 736



View Profile WWW
« Reply #3 on: January 10, 2008, 05:52:31 AM »

Works now. Seems to be a bit slower than normal method but it works!
Logged
pochu
the ubuntu guy
Hero Member
*****

l33tness: 3
Offline Offline

Posts: 141


View Profile WWW
« Reply #4 on: January 10, 2008, 06:55:01 AM »

Could someone explain what are the advantages of the --safe login? Reading the log it sounds to me like it's "safe" as in "better", not as in "secure". But I couldn't find what the ADL command is at http://www.hypothetic.org/docs/msn/index.php . I'd look at the diff but it's *huge* :

The size of the diff (2398 lines) is larger than your specified limit of 1000 lines

And from the "experimental" thing in the log I guess there are no plans for making it default any time soon... right?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!