[Twisted-Python] Migrate Asyncore to Twisted

Sean Roark srock258 at gmail.com
Tue Mar 13 09:03:19 MDT 2007


Thanks Jian. I am actually not sure if it is my protocol that is complicated
or if the way in which I want to pass the data that is complicated. This is
what I'm doing.

I have two devices that both send and recieve binary strings. Each device
formats the binary messages in a completely different manner, but
abstractly, they basicly contain the same information just in different
formats. I need to recieve the data, parse it, translate it, then repack it
into this different raw format and send it to another destination. All this
works just fine using asyncore dispatchers but I have created my own way of
passing the messages between the different modules. Each module I have
(parse, translate, pack, recieve, send) is wrapped by two Queue's, one
taking input and the other taking output. I connect the modules by replacing
one instance's output Queue with another's input Queue. This way each module
is a thread that simply blocks on the input Queue. When the Parse instance
finishes parsing data it puts it on the output Queue which is actually the
Translate modules input Queue. Since everything needs to happen in a nice
linear manner this works great.

But, this means I am not using callbacks or anything. Instead I would need
to wrap the Twisted protocol in my Queue protocol. This seems straight
forward enough, but I don't have much time to make this conversion (charge
number is running out!) which is why I would love to see an example of the
asyncore dispatcher to twisted protocol conversion. It would go along way to
helping me quickly map my existing code to twisted style code.

My reason's for switching to Twisted are for the future. This may need a web
interface for configuration and monitoring in the near future. Also,
asyncore has a myriad of issues on Win32 but we want the program to work on
both *nix and windows, I'm hoping Twisted helps. Furthermore, the Twisted
libraries for making my system an application look very appealing as a means
to ease deployment.

Thanks,

Sean

On 3/13/07, jian wu <hellojianwu at gmail.com> wrote:
>
> Hi Sean,
>
> I had some experience to write a simple python test simulator for my
> java network
> application using Apache Mina for a text line based protocol
>
> At first I used asyncore.async_chat, then I moved to
> twisted.protocols.basic.LineReceiver
> since I need async multi-thread behavior. For me, it is
> straight-forward regarding handling the protocol when moving from
> async_chat to LineReceiver.
>
> And, asyncore.disptacher is just replaced with Twisted reactor and
> Factory or TCPServer
> if you want to write a Twisted Application.
>
> If you have a very complicated protocol, it might be totally different
> from my experience.
>
> Best regards,
>
> Jian
>
>
> On 3/12/07, Sean Roark <srock258 at gmail.com> wrote:
> > I would love to migrate my asyncore based applications to Twisted but
> the
> > learning curve seems quite steep. Anybody have a good tutorial?
> Migrating
> > asyncore.dispatcher objects to twisted protocols examples would be
> awesome.
> >
> > --
> >
> > Sean Roark
> > _______________________________________________
> > Twisted-Python mailing list
> > Twisted-Python at twistedmatrix.com
> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
> >
> >
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>



-- 

Sean Roark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20070313/316b67de/attachment.html>


More information about the Twisted-Python mailing list