← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #693935]: Jython: only one successful connection attempt using sockets

 

Question #693935 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/693935

Damian posted a new comment:
This is the fundamental code snippet which I use to connect as a client
to the server:

import socket

class TCPControler:

    IP = "127.0.0.1"
    PORT = 10002
    
    def __init__(self):
        print('__init__')
        self._TCPSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            self._TCPSocket.connect((self.IP, self.PORT))
        except ValueError as error:
            print(error)
        except OSError as error:
            print("Unable to open TCP port %s:%s" % (self.IP.upper(), str(self.PORT)), error)

    def __del__(self):
        print('__del__')
        self._TCPSocket.close()


def main():
    TcpCtrl = TCPControler()

main()

Moreover, I noticed that destructor in jython works with delay or at all
(I mean that it does not execute its code just after the Jython process
stops working). In order to debug this issue I added the "print"
functions in __init__ and __del__ member functions . It looks like the
__del__ function in jython is invoked while garbage collector starts
working (or similar tool).

Has someboody meet with such issue too?

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.