[Twisted-Python] UDP some Q's

Sven-Erik Tiberg Sven-Erik.Tiberg at ltu.se
Thu May 3 13:11:58 MDT 2007


Thanks 
working on it.
found some fault and learned a lot.
/BG
Sven-Erik
 

________________________________

From: twisted-python-bounces at twistedmatrix.com on behalf of glyph at divmod.com
Sent: Thu 5/3/2007 11:16 AM
To: Twisted general discussion
Subject: Re: [Twisted-Python] UDP some Q's


On 08:42 am, sven-erik.tiberg at ltu.se wrote:

>Don't know how to access objects from the main module in the classes in
>the lib module.
>The tricky part as I see it are ( part of from transive_UDP.py ):
># ------------------------------------------------------------------
> def datagramRecived(self, data):
>        count = 0
>        data_str = string.split(data)
>        for recive_items in data_str:
>            __main__.recived_data[ count ] = float( recive_items )
>            count = count +1
>        __main__.update_on_recive()
>
>#-----------------------------------------------------------------
>The problems are that I need to update __main__.recive.dada before
>calling __main__.updat_on_recive().

There is no Twisted API or special technique that you need to use.  Just create your objects with references to all the objects they need to manipulate.

For example, in main.py, instead of:

    reactor.listenUDP(self.port, transive_udp('...',2345, 0.05 ))

just do:

    reactor.listenUDP(self.port, transive_udp('...', 2345, 0.05, recive_data))

and then add an argument to transive_udp's constructor to refer to the data.

>Second how to access the  .send_UDP from the __main__ module.

Similarly, you can keep a reference to transive_udp object in the main module.

I might be able to comment more except the attached example is full of errors and will not even import.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4770 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20070503/757aae42/attachment-0002.bin>


More information about the Twisted-Python mailing list