Re: [Twisted-Python] Understanding deferred and error handling

2011-04-19 Thread Jason Heeris
On 20 April 2011 12:28, David wrote: > This already bothers me at a fundamental level, because it means it is > very easy to "swallow" errors without being aware of it. Is there a > "systematic" solution to this issue, or am I condemned to handle errors > systematically everywhere in my code ? My

Re: [Twisted-Python] Gtk2Reactor: what are the reasons for avoiding GLib functions?

2011-04-05 Thread Jason Heeris
On 5 April 2011 20:06, Žiga Seilnacht wrote: > I think that the main reason for PortableGtkReactor being used on Windows > is due to glib's IO channels limitations on Windows. You can only have 63 > channels in the event loop at the same time due to g_poll's use of > MsgWaitForMultipleObject. The

[Twisted-Python] Gtk2Reactor: what are the reasons for avoiding GLib functions?

2011-04-05 Thread Jason Heeris
I'd like to try and get to the bottom of the various problems with Twisted + GTK + Windows (mainly issue #4932[1], but see also issues #4376[2], #4862[3], #1759[4]). On issue #4376 there's a comment from Exarkun: "glib handles timeouts much less efficiently than any of the existing Twisted reacto

Re: [Twisted-Python] Fwd: Slow data transfer with Twisted + socat + Windows

2011-03-09 Thread Jason Heeris
On 9 March 2011 15:23, Jason Heeris wrote: > Besides, none of that will help if the GTK reactor can't communicate > with anything properly. I adapted my original script to simply work with an echo server, and there really does seem to be a problem with the GTK reactor, no matt

Re: [Twisted-Python] Fwd: Slow data transfer with Twisted + socat + Windows

2011-03-08 Thread Jason Heeris
On 9 March 2011 15:02, Michael Thompson wrote: > My read of these results is that socat on windows limits the > performance to 30s and in addition the gtkreactor on windows has > performance problems. I'd say it's Cygwin, not socat, but yes. > pyserial includes an example that makes a serial por

Re: [Twisted-Python] Slow data transfer with Twisted + socat + Windows

2011-03-08 Thread Jason Heeris
On 9 March 2011 03:49, Michael Thompson wrote: > Does you program just write via TCP to this serial device, it doesn't > do anything else that could block? Both the "bare bones" script and the real app writes and reads from the device, so I wouldn't expect full speed communications. But I can't s

[Twisted-Python] Slow data transfer with Twisted + socat + Windows

2011-03-08 Thread Jason Heeris
I'm writing an application with Twisted/GTK to manage a serial device, for use on both Windows and Linux. Unfortunately I can't use serial comms directly under Windows[1], so my workaround is to launch socat[2] in a subprocess to relay data between a local TCP port and the serial port. The socat co

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 22:45, Jason Rennie wrote: > Sounds like you just need a queue of pending commands and a state object for > the currently executing command. Just for the sake of completeness, this is what I've ended up with. No explicit queues, and the state is kept with a lock: cla

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 21:30, wrote: > Not intentionally: > >  http://twistedmatrix.com/trac/ticket/3690 Interesting... As an aside, the problem of serial port availability for unit tests is something I've encountered before too. I solved it by using "socat" to create virtual serial ports with kno

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 19:18, Phil Mayers wrote: > For example, if you have a line-based proto it might look like this: Aha, I think you might just have answered my question before I asked it. Which seems appropriate somehow. I think the DeferredQueue does some of this for me, so I'll look into it.

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 16:59, Phil Mayers wrote: > I'm a little confused as to why this is a connectionless protocol, if > it's talking on a serial port? Surely it's a singleton connection, with > no connect/disconnect events? There's a connectionMade event when you do SerialPort(protocol, ...). The

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 18:39, Jason Heeris wrote: > (I would ask: do I even need a factory? But the fact is that I do, > since all of the useful mixins and base classes rely on one being > present.) Just realised that actually, I'm using the TimeoutMixin, not the TimeoutProtocol —

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-21 Thread Jason Heeris
On 21 February 2011 15:58, Michael Thompson wrote: > The app should be waiting on the result of a deferred (which it > expects to fire with the result of the serial comms) so you can simply > errback that deferred. I get that bit, but my question is essentially: what triggers the errback? If the

Re: [Twisted-Python] Error (and response) handling in protocols

2011-02-20 Thread Jason Heeris
On 21 February 2011 14:50, Michael Thompson wrote: > This might be better expressed as how do you write a protocol to > handle errors when using an unreliable transport. It down to your > protocol as to how you need to handle errors by for instance sending a > NACK  or re-transmitting a request.

[Twisted-Python] Error (and response) handling in protocols

2011-02-20 Thread Jason Heeris
I'm still a little confused about exactly how to deal with errors and responses using protocols and factories. I think a lot of my misunderstanding stems from the fact that I'm using serial (and inter-process) communications, both of which Twisted treats rather differently from TCP based connection

Re: [Twisted-Python] DeferredSemaphore - action on acquire and release

2011-02-07 Thread Jason Heeris
On 8 February 2011 12:22, Stephen Thorne wrote: > I totally misread your example, and I appologise. I've read it now and > it looks fine to me. The only commend I'd make is that you probably want > DeferredLock not DeferredSempahore if this is serialised access. No need to apologise, happens to a

Re: [Twisted-Python] DeferredSemaphore - action on acquire and release

2011-02-07 Thread Jason Heeris
On 8 February 2011 11:46, Stephen Thorne wrote: > Um, that's what I mean, you shouldn't be using .acquire() or .release(), > just .run(). doSerialStuff doesn't need a reference to the semaphore > object. So... how can I update the property and emit the signal upon acquisition and release? Or are

Re: [Twisted-Python] DeferredSemaphore - action on acquire and release

2011-02-07 Thread Jason Heeris
On 8 February 2011 10:45, Jason Rennie wrote: > I think what you have duplicating functionality---you're not taking > advantage of the DeferredSemaphore. I thought using the "run" method *was* the preferred way to use a DS, but whatever works. > You'll want "sem" to be a global---use wherever yo

[Twisted-Python] DeferredSemaphore - action on acquire and release

2011-02-07 Thread Jason Heeris
I'm using a DeferredSemaphore with a token count of 1 to control access to a serial port. I also have a GTK object for which I'd like the "in-use" property to change (and notify listeners) when the resource is in use. So far, I have something like this: class SerialResource(gobject): # P

Re: [Twisted-Python] Guidance needed on serial device interaction

2011-02-02 Thread Jason Heeris
On 2 February 2011 17:53, Albert Brandl wrote: > "string" could be interpreted as "complete message". It might e.g. happen > that a message arrives in three chunks. Each time a chunk is read, the > dataReceived method is called. When it detects that the message is > complete, it calls stringReceiv

Re: [Twisted-Python] Guidance needed on serial device interaction

2011-02-02 Thread Jason Heeris
On 2 February 2011 15:58, Michael Thompson wrote: > The job of the protocol class is to assemble the bytes that you > receive into packets or messages. Ideally the protocol will have > characters that frame a message, and it sounds like you might have > this if > or ! is always sent at the end of

[Twisted-Python] Guidance needed on serial device interaction

2011-02-01 Thread Jason Heeris
This is a bit long, sorry... I have a PyGTK program that uses threads and pyserial's blocking methods to interact with an RS232 connected device. I'd like to throw out the threading awfulness and redo it in Twisted, if possible, but I'm a little lost. The real protocol is a bit convoluted, but ba

Re: [Twisted-Python] High-level view of Twisted

2011-01-31 Thread Jason Heeris
On 1 February 2011 13:58, Kevin Horn wrote: > A couple of us are getting fired up about cleaning up the documentation to > make it easier for those new to Twisted to find what they're looking for, so > please do speak up with any feedback you have. My only suggestion is this: no magic! As per my

Re: [Twisted-Python] High-level view of Twisted

2011-01-31 Thread Jason Heeris
On 1 February 2011 13:15, Andrew Bennetts wrote: > Jason Heeris wrote: > [...] >> 2. What is a Factory, anyway? What are they *for*? > > <http://twistedmatrix.com/documents/current/core/howto/glossary.html#Factory> > says: Oh, and I also has a link to a "client

Re: [Twisted-Python] High-level view of Twisted

2011-01-31 Thread Jason Heeris
On 1 February 2011 13:15, Andrew Bennetts wrote: > Jason Heeris wrote: > [...] >> 2. What is a Factory, anyway? What are they *for*? > > (I couldn't resist the opportunity to link to the glossary after the recent > thread about it...) I completely missed the glossary s

[Twisted-Python] High-level view of Twisted

2011-01-31 Thread Jason Heeris
Hi, I'd like to come to grips with Twisted, and so far I've been following and tweaking example after example. But I'm finding it incredibly hard to get a high level view of the Twisted "landscape" — and because I don't know what I don't know, it's hard to know what questions to even ask. I want t