jimstorch / miniboa

Automatically exported from code.google.com/p/miniboa
Apache License 2.0
1 stars 1 forks source link

Telnet session termination #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
To end connection I set connection.active to false and remove it from
connections list but it does not cause session termination. That means that
telnet client still thinks it is connected.

Original issue reported on code.google.com by mich.mierzwa@gmail.com on 22 Dec 2009 at 12:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm having the same issue in my Bogboa codebase, although the chat_server.py 
demo
works just fine.  It's definitely a garbage collection issue but I'm not sure 
if the
problem is in Miniboa.  

Original comment by jimstorch@gmail.com on 22 Dec 2009 at 2:08

GoogleCodeExporter commented 9 years ago
Hmm I have found that you have commented out client.sock.close() in async.py: 
poll.
Why?
I uncomented it and put like this:

            if client.active:
                recv_list.append(client.fileno)
            ## Delete inactive connections from the dictionary
            else:
                #print "-- Lost connection to %s" % client.addrport()
                del self.clients[client.fileno]
                self.on_disconnect(client)
                client.sock.close()

And now connection is properly close.

Original comment by mich.mierzwa@gmail.com on 23 Dec 2009 at 9:48

GoogleCodeExporter commented 9 years ago
I was trying to track down why my bogboa user objects weren't getting garbage
collected.  The call to socket.close() shouldn't be needed if thing are working
correctly as it closes when it's deleted.

The problem I'm having with my user objects (that reference miniboa's client 
object)
is bascially this:

>>> class A(object):
...     def __del__(self):
...             print "__del__ called"
...     def foo(self):
...             pass
... 
>>> a = A()
>>> del a
__del__ called
>>> a2 = A()
>>> a2.bar = a2.foo
>>> del a2
>>> 

Apparently, trying to add a dynamic reference to a method creates a circle.

Original comment by jimstorch@gmail.com on 23 Dec 2009 at 2:26

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This is how I resolved it in my codebase (it was a garbage collection problem 
in my
MUD, not Miniboa);

http://bogboa.blogspot.com/2009/12/dynamic-methods-and-garbage-collecting.html
http://bogboa.blogspot.com/2010/01/work-around.html

I would like to close this issue.

Original comment by jimstorch@gmail.com on 2 Feb 2010 at 1:08

GoogleCodeExporter commented 9 years ago
Thanks for links. I must admit that I decided to just close connections 
manually. I 
do not know if GC sweeps then the stuff (I hope that it eventually do). If it 
becames a problem I would have to check any circular referencess I guess.

Original comment by mich.mierzwa@gmail.com on 3 Feb 2010 at 7:20

GoogleCodeExporter commented 9 years ago
Do you have a project page where I could look at your code?  You might also 
want to
check out Python's weakref module:

http://docs.python.org/library/weakref.html
http://www.doughellmann.com/PyMOTW/weakref/index.html

Original comment by jimstorch@gmail.com on 3 Feb 2010 at 1:27

GoogleCodeExporter commented 9 years ago
You are welcome http://trac.xp-dev.com/pymud/browser
But remember that it is at very early stage so it is not clean and commented as 
your 
code is. 
I am also beginner in Python.

Original comment by mich.mierzwa@gmail.com on 4 Feb 2010 at 7:23