Re: [Twisted-Python] overview: new review queue venue

2016-05-21 Thread Terry Jones
Hi Glyph On Sun, May 22, 2016 at 12:12 AM, Glyph wrote: > - Reviewing: This is the potentially slightly odd part. I believe a > review that doesn't result in acceptance should *close* the PR. This feels wrong to me. I find github pull requests very useful, in ways that it sounds like your sug

Re: [Twisted-Python] A little present for emacs / flycheck users

2016-02-09 Thread Terry Jones
There used to be some elisp in Twisted, called something like twisted-dev-mode.el (written, I think, by Glyph or JP). That added a find-file-hook based on the prefix of the path of the file you were about to edit. I still use it, and some small modifications, for a customized dev mode in various p

Re: [Twisted-Python] asynchronous response

2015-12-17 Thread Terry Jones
Hi Kevin I found it extremely beneficial to read the Twisted sources, in particular twisted.internet.defer. In your case, see https://github.com/twisted/twisted/blob/trunk/twisted/internet/task.py#L821 One nice thing that happens when you read the source is that you see quite a number of API meth

Re: [Twisted-Python] txdlo - a Twisted DeferredListObserver

2013-12-30 Thread Terry Jones
Hi Hynek On Mon, Dec 30, 2013 at 11:54 PM, Hynek Schlawack wrote: > if I can pester you any further: I’d appreciate a wheel and you can have a > more useful PyPI entry Thanks for your PyPI guide, it's great. I updated to include a wheel. I tried about 5 different ways to get it to install pac

Re: [Twisted-Python] txdlo - a Twisted DeferredListObserver

2013-12-30 Thread Terry Jones
https://github.com/terrycojones/txdlo Terry On Mon, Dec 30, 2013 at 9:37 AM, Hynek Schlawack wrote: > On 30 Dec 2013, at 6:24, Terry Jones wrote: > > > I'll improve the examples (and probably add tests for them) at some > point. > > Meanwhile, the DeferredListObserver c

[Twisted-Python] txdlo - a Twisted DeferredListObserver

2013-12-29 Thread Terry Jones
I just wrote a quick class called DeferredListObserver that lets you do various things with a list of deferreds. You can add observers that get passed information about the deferreds firing. You can also add deferreds to the observed list at any time (this is very useful if you're dynamically creat

[Twisted-Python] Deferreds / promises as first-class objects for function calls

2013-09-11 Thread Terry Jones
I just wrote a blog post that people who like thinking about deferreds might find interesting. Somehow it took me 7 years to one day look at deferreds in this way: http://blogs.fluidinfo.com/terry/2013/09/12/promises-are-first-class-objects-for-function-calls/ (With apologies for mainly describing

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
JP writes: On Thu, Aug 29, 2013 at 1:00 PM, wrote: > Keep in mind that the Deferred cancellation API is a "best effort" API. > There are no guarantees that anything can be cancelled. Consider the fact > that 90% or more of Deferreds out there don't even have cancellation > implemented for them

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
JP writes: On Thu, Aug 29, 2013 at 1:00 PM, wrote: > What about a third option - if a cancellation function raises an > exception, fail the Deferred with that exception. I really like this idea, but it wont work if the cancel function has already fired the deferred. Terry

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
Hi Kai I think it's helpful to keep clear on two different things that cancelation is intended to do: 1) to fire the original deferred so that things relying on it can proceed, and 2) to try to terminate an ongoing action that the deferred might be waiting on. For 1, I think calling cancel() shou

[Twisted-Python] Interesting plot on new author contributions post-Github for several Python packages

2013-08-26 Thread Terry Jones
This doesn't prove anything, but I think the first plot at http://jakevdp.github.io/blog/2012/09/20/why-python-is-the-last/ is quite provocative. Semi-related: I made a tiny optimization to jQuery a couple of months ago as a completely unknown first-time contributor. The time from doing the git cl

Re: [Twisted-Python] Trial & the mock library

2013-07-26 Thread Terry Jones
> That sounds like a great idea, I wonder if anyone's thought of it before. I suggested this in #twisted a few years back and was immediately told it was a bad idea (names withheld!). Another case in which this pops up is if you accidentally yield some deferreds in a test but don't decorate with

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-22 Thread Terry Jones
Hi Tom I'm not sure we should continue this discussion on the list seeing as the original issue seems to be settled. Anyway, here's an answer and maybe we could/should take it offline if there's more to say? On Sat, Jun 22, 2013 at 11:14 PM, Tom Prince wrote: > Terry Jone

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-21 Thread Terry Jones
Hi JP Thanks for the summary. I agree (and agreed in my first post in this thread) that the CancelledError should (has to) come all the way back. I missed that we were still talking about that. Was there a conclusion on Glyph's suggestion of using subclasses of CancelledError? Chris raised the po

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-21 Thread Terry Jones
ng to provide for. The ControllableDeferred2013 class I posted last night shows one way. Adding a value arg to cancel() would build some of that flexibility into Twisted itself. Hopefully that helps makes things clearer. Terry On Fri, Jun 21, 2013 at 7:18 AM, Tom Prince wrote: > Terry Jones

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-21 Thread Terry Jones
7;hey' Terry On Fri, Jun 21, 2013 at 6:12 AM, Tom Prince wrote: > Terry Jones writes: > > OK, maybe someone can explain the original "Well, it already raises > > `CancelledError`. Every deferred that doesn't have explicitly handle > > cancelling already does:

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-20 Thread Terry Jones
By the way, I don't need any of this to make its way into Twisted. I can still write my own class that does what I want (well, wanted). Below is a 2013 version of the CancelableDeferred. It's untested. The basic idea is that if you get a regular deferred from somewhere, you can use the class belo

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-20 Thread Terry Jones
Hi JP > This is not to say that I believe there is no application that might want this information, but maybe someone can > propose some concrete use cases for this information and design can follow from that. So far I don't think any > practical justification to do anything other than `Cancelled

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-20 Thread Terry Jones
> Thank you for pointing this out. It seems like an important fact that makes the rest of the discussion moot. OK, maybe someone can explain the original "Well, it already raises `CancelledError`. Every deferred that doesn't have explicitly handle cancelling already does:" to me, because I didn't

Re: [Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?

2013-06-18 Thread Terry Jones
First off, +1 on propagating the CancelledError failure (or something even more specific) all the way back up the errback chain. lvh> Personally, I think it's enough of a change in functionality to warrant a chance in ways a function can fail I'm not sure what change in functionality you mean. De

Re: [Twisted-Python] reload / restart best practices ?

2013-06-12 Thread Terry Jones
Hi Jonathan You might also find something like this useful: http://twistedmatrix.com/pipermail/twisted-python/2009-December/021107.html Optionally, it would be easy to add a timeout value to the class that could cancel outstanding deferreds after a certain amount of time and then fire all the wai

Re: [Twisted-Python] github, again

2013-06-08 Thread Terry Jones
Hi Tom Here are some comments on your thoughts (again, I'm no expert or authority). On Sat, Jun 8, 2013 at 5:07 PM, Tom Prince wrote: > Although being able to comment on the diff inline is very convenient, my > experience is that this encourages looking at changes in a line-by-line > fashion, >

Re: [Twisted-Python] github, again

2013-06-04 Thread Terry Jones
> So when the code is ready, the feature branch including any accumulated commits (history) will > get merged - and not a clean diff against the main repo? I'm very far from being a git expert. In fact, I'm kind of the opposite - git and I have a stormy relationship and everyone has to tell me wha

Re: [Twisted-Python] github, again

2013-06-04 Thread Terry Jones
The general workflow that's being described is: - You open an issue for all bugs, enhancements, etc. - When someone starts working on one of these, they create a branch (we use descriptive branch names and put - at the end, with the issue number). - When the branch reaches the point where t

Re: [Twisted-Python] github, again

2013-06-03 Thread Terry Jones
I sent most of the below off-list to Glyph earlier, as my comments were a bit half-assed and I'm not really (or not at all) a Twisted contributor. Glyph suggested I mail them to the list anyway, and to try adding some more concrete reasons for being +1 on the suggested change. --- [ Original mail

Re: [Twisted-Python] Simpler Twisted deferred code via decorated callbacks

2012-10-15 Thread Terry Jones
Here's a description of what the 'errback' decorator in my code does. (BTW, I've just updated it.) Here's normal Twisted errback code, assuming you do from twisted.web.client import getPage and from twisted.python import log. def logGetPageError(url): def handleError(failure, url):

Re: [Twisted-Python] Simpler Twisted deferred code via decorated callbacks

2012-10-15 Thread Terry Jones
Here's a description of what the 'callback' decorator in my code does. Here's some normal Twisted code, assuming you do from twisted.web.client import getPage (yes, getPage is kind-of obsolete, but it's a concrete and conceptually simple deferred-returning function I like to use in examples).

Re: [Twisted-Python] Simpler Twisted deferred code via decorated callbacks

2012-10-15 Thread Terry Jones
Hi Naveen > This is a really nice approach. I'm glad you like it. I've learned over the years to avoid decorators, but I nevertheless think these ones are promising. > Are there any downsides or functionality that can't be accomplished using > this approach? The main thing that's a little diffe

[Twisted-Python] Simpler Twisted deferred code via decorated callbacks

2012-10-15 Thread Terry Jones
This morning I was thinking about deferreds and how people find them difficult to grasp, but how they're conceptually simple once you get it. I guess most of us tell people a deferred is something to hold a result that hasn't arrived yet. Sometimes, though, deferreds do have a result in them immed

Re: [Twisted-Python] deferred graph?

2012-06-28 Thread Terry Jones
Hi Glyph! There are a couple of tickets floating around: http://twistedmatrix.com/trac/ticket/3858 http://twistedmatrix.com/trac/ticket/1402 (closed as a dupe) T ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix

Re: [Twisted-Python] deferred graph?

2012-06-28 Thread Terry Jones
Hi Dan > I'm a Twisted neophyte, but I've been using Python a long time. I'm a Twisted neophyte, but I've been using Twisted a long time. (I'd add a smiley, but that's not a joke.) > My question: Is there a way of producing a deferred graph in a Python > program at a given point in time? Perha

Re: [Twisted-Python] running 1,000,000 tasks, 40 at-a-time

2011-10-26 Thread Terry Jones
Hi Jason > I don't see anything in task.Cooperator to limit the # of > simultaneously-running tasks. Am I missing something? I'm not sure, but I think so. It does limit the number of simultaneously-running tasks. > I guess, technically, could write my own scheduler that limits the # of > simul

Re: [Twisted-Python] running 1,000,000 tasks, 40 at-a-time

2011-10-26 Thread Terry Jones
Hi Jason > - Is there a Twisted pattern for managing tasks efficiently that I be > - missing? Sounds like you should be using a Python generator and that you're not. First off, have you read http://jcalderone.livejournal.com/24285.html ? If not, do. Take note of the line work = (callable

Re: [Twisted-Python] Passing extra arguments along callbacks

2011-10-21 Thread Terry Jones
Hi Jonathan > def resolve(ip): > ptr = '.'.join(ip.split('.')[::-1]) + '.in-addr.arpa' > return client.lookupPointer(ptr).\ > addCallback(lambda x: (ip, x)).\ > addErrback(lambda x: (ip, x)) Your errback isn't raising and isn't returning a Failure, so the processin

Re: [Twisted-Python] How to safely stop a chain of deferreds

2011-06-28 Thread Terry Jones
Hi Tom > in a GUI application I'm using quite a comprehensive chain of deferreds > and I'm running the mainloop from the glib2reactor. At a certain point of > my application I need to terminate the entire chain of deferreds to make > sure that no more data is loaded and processed. Stopping the rea

Re: [Twisted-Python] Question about "starving" the reactor

2011-06-20 Thread Terry Jones
I posted to the mailing list a few years back with a Deferred class that can log what callbacks were called, what result they returned, etc. It would be very easy to add callback timing information to that. You'd just insert a callback into the chain of any deferred you wanted to monitor to have it

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Terry Jones
Hi Sergey > def checkObsolete(item): > if item.obsolete(): > return None > else: > d = item.read() > d.addBoth(release, item) > d.addCallback(renew) > return d > > d = cache.open(key) > d.addCallbacks

Re: [Twisted-Python] help with Deferreds

2010-08-26 Thread Terry Jones
Hi Sergey > How to rewrite this regular function with Deferred-style? Something like the below (untested) will do the job. You'd have to make sure that cache.open returned a deferred that fails with NotFound in case things don't work out. It would be simpler to translate your code using inlineC

[Twisted-Python] Deferred's chainDeferred is too simplistic?

2010-08-13 Thread Terry Jones
I think it's worth spending some time thinking about whether chainDeferred in t.i.defer.Deferred is too simplistic. I've thought for a while that it could be more helpful in preventing people from doing unintended things and/or cause fewer surprises (e.g., see point #1 at http://bit.ly/bp6iT5 which

Re: [Twisted-Python] conceptually, why a deferred can't be used more than once?

2010-07-08 Thread Terry Jones
Hi Jean > Concerning the concept of the deferred, why is it more useful to go with > a deferred which gets consumed and can only be fired once? I can't speak for the Twisted devs, but my #1 reason would be that it's just simpler that way (and Deferreds are already complex enough). > In my small

[Twisted-Python] Looking for Twisted programmers at Fluidinfo

2010-05-27 Thread Terry Jones
Apologies for a job posting, but we're looking to hire Twisted people at Fluidinfo (http://fluidinfo.com) . We wrote FluidDB using Twisted from top to bottom. We love Twisted. In fact, we closed a funding deal a week ago and the company's first check is being written to the Twisted Software Founda

Re: [Twisted-Python] twisted.web in 60 seconds...why aren't these on the frontpage of TM.com?

2010-04-21 Thread Terry Jones
> If it's of any use, someone started trying to do this, and got at least > as far as deleting all of the front page content: > > http://twistedmatrix.com/trac/wiki/TestFrontPage Awesome. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.

Re: [Twisted-Python] Try/catching yielded Exceptions and getting proper tracebacks

2010-02-22 Thread Terry Jones
Hi Paul > "Paul" == Paul Goins writes: You're only printing the exception, not a full traceback, so you don't see much. I tend to write what you're doing as follows: from twisted.python import log @defer.inlineCallbacks def xmlrpc_dosomething(self): d = self._do_somethi

Re: [Twisted-Python] Lore to Sphinx Conversion Progress Report 5

2010-02-05 Thread Terry Jones
Hi Kevin I just tried building under Python 2.5.2 and got this: $ python lore2sphinx.py Traceback (most recent call last): File "lore2sphinx.py", line 32, in from table import Table File "/home/terry/s/net/lore2sphinx/table.py", line 214 row_lines = list(izip_

Re: [Twisted-Python] Lore to Sphinx Conversion Progress Report 5

2010-02-05 Thread Terry Jones
> - It looks fine under Google chrome Argh, having said that, I just noticed the table of contents is below and to the right of the main page content. An example page that exhibits this is http://twistedsphinx.funsize.net/projects/conch/howto/conch_client.html Terry ___

Re: [Twisted-Python] Lore to Sphinx Conversion Progress Report 5

2010-02-05 Thread Terry Jones
Hi Kevin I think this is looking really good. Here are a few superficial / quick comments. - It looks fine under Google chrome - You could reduce visual repetition / density of some of the high-level pages by taking out a word like "Documentation" which appears in the heading and on ever

Re: [Twisted-Python] understanding deferreds

2010-02-01 Thread Terry Jones
> "Alexey" == twisted-web writes: Alexey> Is it true, that adding many callback functions as filters is Alexey> elegant, but impractical solution? Many callbacks as a filter is elegant & practical. But there's a difference with errbacks, as people are touching on. That's, with a bit of han

Re: [Twisted-Python] PyCon 2010 Twisted Sprint

2010-01-31 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> I will be there for one day of the sprints. I'm interested in web2, Glyph> deferred cancellation, endpoints, and getting a new release out. I could probably stay for most/all of the 22nd. Doing some work on deferred cancellation would be good. Ter

Re: [Twisted-Python] understanding deferreds

2010-01-28 Thread Terry Jones
> "Michael" == Michael P Soulier writes: Michael> I'm a bit confused as to the "visual explanation". It seems like Michael> if you have a single callback and errback, that if the errback Michael> wants to swallow the error, the callback will not be called at Michael> all, since deferred proce

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-07 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> This implies, to me, that the cancellation callback would be better Glyph> passed to addCallbacks(): effectively creating a third callback Glyph> chain going from invoker to responder rather than the other way Glyph> 'round as callbacks and errbacks

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-06 Thread Terry Jones
Hi Glyph It's very late here, so I'll limit myself to a few thousand lines of reply. >>>>> "Glyph" == Glyph Lefkowitz writes: Glyph> On Jan 6, 2010, at 7:09 AM, Terry Jones wrote: Glyph> What I mean is, there are a lot of weird little edge-cases i

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-06 Thread Terry Jones
>>>>> "Glyph" == Glyph Lefkowitz writes: Glyph> On Jan 5, 2010, at 4:53 PM, Terry Jones wrote: Glyph> I understand what you're saying: you're interested in a subset of Glyph> what I'm interested in, here. Yes. Glyph> The point I'm try

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-05 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> And let's not forget, in long-running servers, it's possible to Glyph> "leak" operations, and the associated resources like file Glyph> descriptors. When the caller says that they're not interested in Glyph> the result of an operation any more, the

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-05 Thread Terry Jones
>>>>> "Tristan" == Tristan Seligmann writes: Tristan> On Tue, Jan 5, 2010 at 6:29 AM, Terry Jones wrote: >> - Once someone has made a function call, gotten a deferred, added >> ?call/errbacks to it, etc., it's gone. It's in flight. Forget abo

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-05 Thread Terry Jones
Argh. sorry, there was a trivial cut & paste error in the code I just posted. The errback method should of course be: def errback(self, fail=None): if not self._called: self._called = True defer.Deferred.errback(self, fail) Terry _

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-05 Thread Terry Jones
Hi again Glyph, Andrew Below is a simpler and more flexible ControllableDeferred class. The idea is simple: you want a deferred that you can call/errback yourself, and which you can also deactivate so that it never fires. This is done by manipulating two normal deferreds (self, and a deferred re

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-05 Thread Terry Jones
> "Andrew" == Andrew Bennetts writes: Andrew> I think the key thing is to remember there are two distinct parts: Andrew> 1) an operation (which eventually will have a result or failure) Andrew> 2) a result Andrew> A Deferred takes care of managing 2. It's a placeholder for that Andrew>

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-04 Thread Terry Jones
As a final followup before bed... I chose not to have a 'cancel' method on my class because that seemed misleading. You're not really canceling anything. You're just asking that a deferred that you got earlier be fired right now with a value of your choosing. So I made 2 methods, and named them 'c

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-04 Thread Terry Jones
Hi Glyph I read through without trying to get all the details (some are not relevant to me, see below). I'll make a few comments here, then continue in the ticket, supposing there's interest. - It would simplify things to separate discussion of cancelin

Re: [Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-04 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> I already lost you at the first sentence. :-) Sorry. Glyph> The class below never appears to use 'self._f' Oops, that should have been a self._f in the call method. Glyph> and ... Deferreds are things that fire, I don't see how the callable Glyp

[Twisted-Python] A pseudo-deferred class that can be canceled

2010-01-04 Thread Terry Jones
I just wrote the below for fun. It's untested :-) It's a class that you initialize with a callable (f), and which gives you back a deferred (d) that will fire when f fires. Alternately, you can fire d yourself by calling 'callback' or 'errback' on the class instance and passing a value. That val

Re: [Twisted-Python] Problem fetching page with getPage

2010-01-02 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> I'm glad that you tracked this down! Me too. Glyph> According to comments on , Glyph> this problem was addressed in the new HTTP client implementation. Glyph> Have you considered using the new twisted.web.

Re: [Twisted-Python] Problem fetching page with getPage

2010-01-02 Thread Terry Jones
Hi Glyph Thanks for the reply. I just sent another mail in the thread. > "Glyph" == Glyph Lefkowitz writes: Glyph> Well, I know this isn't terribly helpful, but "a bug in getPage" is Glyph> really the only thing that comes to mind. Or, some Glyph> legal-but-unusual behavior in getPage which

Re: [Twisted-Python] Problem fetching page with getPage

2010-01-02 Thread Terry Jones
>>>>> "Steve" == sstein...@gmail com writes: Steve> On Jan 2, 2010, at 9:34 AM, Terry Jones wrote: >> In any case, it looks like the problem is not in the setup of the request. >> Can anyone offer a reason why httplib might be able to fetch the page &g

[Twisted-Python] Problem fetching page with getPage

2010-01-02 Thread Terry Jones
I've run into a problem fetching an HTTP page with t.w.client.getPage. It's not simple to make standalone code showing what's going wrong, but the following summarizes where I am and why I find this puzzling. After some setup, I have some a url path, and some headers I want to send. A summary:

Re: [Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-21 Thread Terry Jones
I forgot to mention that I put the code for this class onto Launchpad: https://launchpad.net/txrdq Terry ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Re: [Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-11 Thread Terry Jones
> "Dave" == Dave Peticolas writes: Dave> Cool. What about being able to get the set of underway objects, in Dave> addition to the set of pending objects? Then you can get the whole Dave> state of the queue at that point. I added an underway() method that gets you a set of underway jobs, each

Re: [Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-10 Thread Terry Jones
> "Dave" == Dave Peticolas writes: Dave> This is really nifty. I know I could use this. Great. Me too :-) >> There's also the issue about what to do when the dispatch function hits >> an error. An option could be added to re-queue the job, but it's >> perhaps better to let the dispatch func

Re: [Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-09 Thread Terry Jones
glyph> Heh. For something in a pastebin, that's all I got :). Stick it in glyph> version control somewhere! Will do. I'm just adding pause/resume, following the suggestion of Dave Peticolas (thanks Dave). Terry ___ Twisted-Python mailing list Twiste

Re: [Twisted-Python] HTML shoudl not be baked into twisted.web HTTP implementation

2009-12-09 Thread Terry Jones
> "James" == James Y Knight writes: James> Essentially every web server on the internet responds with HTML to James> error conditions, so you should probably modify your client. But there are plenty of clients that can't or don't want to or shouldn't have to handle HTML. James> As I said, I'

Re: [Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-09 Thread Terry Jones
>>>>> "Glyph" == Glyph Lefkowitz writes: Glyph> On Dec 8, 2009, at 11:09 PM, Terry Jones wrote: >> I just wrote a fun class that lets you >> >> - submit jobs to be dispatched to a queue >> - manage how many tasks are in progress at once >&g

[Twisted-Python] A resizable cooperator class for queuing and dispatching jobs

2009-12-08 Thread Terry Jones
I just wrote a fun class that lets you - submit jobs to be dispatched to a queue - manage how many tasks are in progress at once - dynamically adjust that number - shut down cleanly, including - recovering jobs that were queued but hadn't been dispatched This uses a combination of

[Twisted-Python] A simple DeferredPool class

2009-12-06 Thread Terry Jones
I submitted a talk on Twisted Deferreds to the US PyCon about, but it was unfortunately rejected. The main point I'd planned to make was how nice the deferred mechanism is, as evidenced by the number of times I've wanted to do things that might be complex in other scenarios but which just fall out

Re: [Twisted-Python] tee method in twisted.internet.defer.py ?

2009-11-17 Thread Terry Jones
> "JP" == exarkun writes: JP> We implemented this 5 or 6 times at Divmod. I'm not surprised. Given that I'd have thought it would've made it into defer.py at some point. JP> The most recent incarnation looks like this: JP> http://divmod.org/trac/browser/trunk/Epsilon/epsilon/pending.py Tha

[Twisted-Python] tee method in twisted.internet.defer.py ?

2009-11-17 Thread Terry Jones
Is there a reason why the Deferred class doesn't have a tee method like the following (untested)? def tee(self, d): def _cb(arg): d.callback(arg) return arg def _eb(arg): d.errback(arg) return arg return self.addCallback

Re: [Twisted-Python] The case of the missing Traceback

2009-11-03 Thread Terry Jones
> "Dan" == Dan writes: Dan> I was playing around with Twisted today and ran into a problem where Dan> Tracebacks aren't emitted on stderr after a deferred callback from a Dan> process called launched by reactor.spawnProcess. The simplified test Dan> case is below. I put "x = y" in the callb

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Hi Tim > Since this is a generator function, it will automatically raise > StopIteration once control-flow falls off the end of the function, so your > while-loop could just be written: Ah yes, thanks a lot. Terry ___ Twisted-Python mailing list Twist

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Hi Blair > Looks pretty good. To streamline the usage and make the intent more > apparent from a brief glance at the header you might consider turning it > into a decorator, like Thanks for the suggestion & the pointer. I'd not seen that page. I don't think this is well suited to decorators, at

Re: [Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
Following up on my own post: > When the backoff iterator finishes, the RetryingCall class gives up on > trying to get a non-error result from the function. In that case you just > get a StopIteration exception in the failure that start() deferred > returns (I was originally returning the original

[Twisted-Python] Retrying function calls

2009-11-01 Thread Terry Jones
These days I often find myself writing code to talk to services that are periodically briefly unavailable. An error of some kind occurs and the correct (and documented) action to take is just to retry the original call. Examples include using Amazon's S3 service and the Twitter API. In both of thes

Re: [Twisted-Python] Can browse, but getPage() fails on localhost address

2009-10-29 Thread Terry Jones
> "Steve" == Steve Steiner (listsin) writes: Steve> curl http://localhost/w3c-validator/check <-- returns HTML code Steve> any browser to http://localhost/w3c-validator/check <-- returns HTML code Steve> t.w.c.getPage("http://localhost/w3c-validator/check";) <--

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Terry Jones
> "Brian" == Brian Granger writes: Brian> I looked at deferLater, but am not using it right now. The sleep Brian> function I am using is basically the same as this - in my case Brian> "sleep" turned out to be a little simpler because I don't have to Brian> create and pass the clock around. B

Re: [Twisted-Python] How to chain deferred calls

2009-10-22 Thread Terry Jones
> "vitaly" == vitaly writes: vitaly> Thank you a lot for pointing me to the Twisted doc-s, but we're vitaly> discussing the following snippet: [snip] vitaly> and basically, I've expected in case of exception vitaly> self.handleFailure1() to be called, but I don't see it happen. The reason y

Re: [Twisted-Python] txRedis - Redis Client for Twisted

2009-10-21 Thread Terry Jones
Hi Dorian > I have created a Twisted version of redis.py. Cool! I'll certainly take a look. Thanks for releasing it. BTW, it would be good to get this into https://launchpad.net/tx, presumably by mirroring to Launchpad. Terry ___ Twisted-Python mail

Re: [Twisted-Python] Trial: Blocking until all deferreds have fired in test

2009-09-25 Thread Terry Jones
Hi Mark. I'd write your FooListener class like this (untested): class FooListener(object): def fooBar(): d = doSomeSetup() d.addCallback(lambda ign: doSomethingThatReturnsADeferred()) d.addCallbacks(lambda ign: 'success!', lambda ign: 'failure!') return d And

Re: [Twisted-Python] Unit tests, inline callbacks, and exception handling

2009-09-24 Thread Terry Jones
Hi Patrick You have try: client2 = Client(username = "Test") yield client2.connect(port = server_port) assert False except UsernameAlreadyExists, ex: pass You could instead try: client2 = Client(username = "Test") d = client2.connect(port = server

Re: [Twisted-Python] Twisted, PushProducer, Words & big msgs, any limit?

2009-08-13 Thread Terry Jones
> "Gabriel" == Gabriel Rossetti writes: Gabriel> I have a sort of XMPP router I wrote using Twisted and there seems Gabriel> to be a size limit of some sort. I have been using it for over a Gabriel> year now without any problems, but today I had a larger than usual Gabriel> msg (175213 bytes)

Re: [Twisted-Python] newb help needed on syslog

2009-08-12 Thread Terry Jones
> "Rebs" == Rebs Guarina writes: Rebs> I'm currently looking at writing a remote syslog client (logs go to a Rebs> central log server running syslog-ng) using twisted. Do you guys have Rebs> any tips on this? If this somewhat appears to be a repost, please Rebs> kindly redirect me to the appro

Re: [Twisted-Python] Deferred documentation rewrite

2009-07-31 Thread Terry Jones
> "Michael" == Michael Hudson writes: Michael> The accompanying paper is here: http://mumak.net/stuff/twisted-intro.html I agree, that's a really nicely done document. It would be good to extend it, moving into a description and explanation of deferreds. Terry

Re: [Twisted-Python] Deferred documentation rewrite

2009-07-30 Thread Terry Jones
> Right. Everything you could do synchronously, you can do asynchronously > (and a bit more too). It just /looks/ really weird. At some point I realized that it helps to realize that code that looks synchronous really isn't at all. Probably all the programming that almost all of us will ever do

Re: [Twisted-Python] LoopingCall at a non-idling reactor

2009-07-18 Thread Terry Jones
> "Glyph" == Glyph Lefkowitz writes: Glyph> On Sat, Jul 18, 2009 at 3:33 PM, Ilya Etingof wrote: >> I can't get Twisted reactor calling my function in a more or less >> periodic fashion with the LoopingCall mechanics. >> >> With select()-based reactor, the LoopingCall object seems to call bac

Re: [Twisted-Python] Twisted meetup/discussion at EuroPython?

2009-06-29 Thread Terry Jones
Hi Richard That sounds good. You might enjoy Esteve Fernandez's talk at 11:30, which is about how we're using Twisted plus Thrift and AMQP for messaging / RPC. Terry Enviado desde mi dispositivo BlackBerry® de Orange. ___ Twisted-Python mailing list T

Re: [Twisted-Python] inlineCallbacksDecorator

2009-06-08 Thread Terry Jones
>>>>> "Drew" == Drew Smathers writes: Drew> On Sat, Jun 6, 2009 at 9:41 PM, Terry Jones wrote: >> One inconvenience with inlineCallbacks is that you might have some kind >> of processing you want done no matter how the function returns, or >> wherever

Re: [Twisted-Python] copy domish element

2009-06-08 Thread Terry Jones
Hi Jack > "Jack" == Jack Bates writes: Jack> i have a domish element - when i try the following, message = element del message['from'] element['from'] Jack> - i get a key error Jack> to avoid this key error, i think i want to copy the element, so i can Jack> drop the 'from'

Re: [Twisted-Python] inlineCallbacksDecorator

2009-06-07 Thread Terry Jones
Hi Maarten > "Maarten" == Maarten ter Huurne writes: Maarten> As far as I can see, this decorator could be applied to any Maarten> function that returns a Deferred, not just to inlineCallbacks. Yes, that's right, and it could be used in that case if you didn't want to deal with the deferred

[Twisted-Python] inlineCallbacksDecorator

2009-06-06 Thread Terry Jones
I try to avoid using inlineCallbacks. There are two cases where I will happily use it though: when I write a method that would need more than a few callback functions, and, more importantly, when the logical flow of a method is non-trivial (i.e., it depends on the returned values or errors of sever

Re: [Twisted-Python] twisted.internet.task.LoopingCall

2009-06-04 Thread Terry Jones
> "Doug" == Doug Farrell writes: Doug> Is there anything in LoopingCall to keep it from trying to run Doug> someFunction() if the previous call is still running? For instance a Doug> call to someFunction() takes longer than 5 seconds, will LoopingCall Doug> hold off or will it call someFuctio

Re: [Twisted-Python] How to make a service dependent of another?

2009-05-15 Thread Terry Jones
> "Gus" == coder gus writes: Gus> I have a pb client and a tcp server. How can I make the server start Gus> only after/if the client started? Hi Gus You might take a look at the code here http://www.twistedmatrix.com/pipermail/twisted-python/2009-February/019249.html and if you go back

Re: [Twisted-Python] Consistent interfaces to asynchronous partially-available services using Deferreds and state machines (was Re: Another approach to allowing __init__ to work with Deferreds)

2009-05-14 Thread Terry Jones
> "Phil" == Phil Christensen writes: Phil> I don't know if I agree with the need for such a feature (that is, Phil> deferred __init__ usage), but it was a very interesting coding Phil> challenge I wanted to take a whack at. I *think* I might have found a Phil> solution, but I don't know if it

Re: [Twisted-Python] Consistent interfaces to asynchronous partially-available services using Deferreds and state machines (was Re: Another approach to allowing __init__ to work with Deferreds)

2009-05-12 Thread Terry Jones
Hi Glyph > "glyph" == glyph writes: > On 11 May, 04:19 pm, terry.jo...@gmail.com wrote: > > >I posted to this list back in Nov 2008 with subject: > >A Python metaclass for Twisted allowing __init__ to return a Deferred > > Let me try rephrasing your use-case here, for two reasons: one, I w

  1   2   >