#twisted

/

      • tenth has quit
      • daniele_athome has quit
      • daniele_athome joined the channel
      • kenaan
        glyph reviewed <https://tm.tl/#5645>; - Document the correct way to deprecate a function in Twisted (assigned to adiroiban)
      • terrycojones has quit
      • terrycojones joined the channel
      • itamar has quit
      • daniele_athome has quit
      • aenglander has quit
      • new core defect https://tm.tl/#8309 by hawkowl: Twisted's coding standard does not ban the use of assertion statements
      • new core enhancement https://tm.tl/#8310 by hawkowl: Twisted's coding standard should state the convention for whitespace before inline comments
      • 03hawkowl 10r4733214 trunk/twisted 05A(8304.misc) 07M(adbapi.py): Merge adbapi-txchecker-8304: Fix some low-hanging TwistedChecker errors in twisted.enterprise.adbapi. ...
      • hawkowl closed <https://tm.tl/#8304>; - twisted.enterprise.adbapi has a lot of simple twistedchecker errors
      • aljohri joined the channel
      • runciter joined the channel
      • runciter has quit
      • Mixologi- joined the channel
      • runciter joined the channel
      • runciter has quit
      • tonythomas joined the channel
      • runciter joined the channel
      • chelly joined the channel
      • oberstet joined the channel
      • chelly has quit
      • floyd joined the channel
      • floyd has quit
      • evilaliv3 joined the channel
      • __marco joined the channel
      • evilaliv3 has quit
      • licensed has quit
      • daniele_athome joined the channel
      • licensed joined the channel
      • mat^2 joined the channel
      • castlelore joined the channel
      • garetjax joined the channel
      • floyd joined the channel
      • garetjax has quit
      • ccxQ has quit
      • ccxQ joined the channel
      • castlelore joined the channel
      • kolko_ joined the channel
      • floyd has quit
      • daniele_athome has quit
      • daniele_athome joined the channel
      • charlemagne joined the channel
      • darkhorse has quit
      • darkhorse joined the channel
      • runciter has quit
      • floyd joined the channel
      • Lukasa submitted <https://tm.tl/#8191>; - Hide the transport backing the HTTPChannel object from twisted.web Resource objects. (unassigned) for review
      • floyd1 joined the channel
      • adamdangoor joined the channel
      • floyd has quit
      • garetjax joined the channel
      • aljohri joined the channel
      • efphe joined the channel
      • MiB joined the channel
      • terrycojones has quit
      • robbyoconnor joined the channel
      • evilaliv3 joined the channel
      • clokep joined the channel
      • robbyoconnor joined the channel
      • robbyoconnor has quit
      • robbyoconnor joined the channel
      • evilaliv3 has quit
      • ssbr_at_work joined the channel
      • daniele_athome has quit
      • itamar joined the channel
      • daniele_athome joined the channel
      • heftig joined the channel
      • heftig
        is the latest and greatest way to have a web server as a Service to subclass StreamServerEndpointService and override __init__(serverFromString(reactor, "tcp:80"), Site(SomeResource())) ?
      • jonathanj
        i'm pretty sure subclassing is not how you're supposed to do it
      • heftig
        subclass MultiService instead and add the stream server service as a subservice?
      • jonathanj
        pretty sure you're not supposed to subclass MultiService
      • it has methods for adding stuff to it
      • i think this is what you want:
      • `strports.service('tcp:80', Site(SomeResource()))` will give you an IService
      • which you can set on your application or add to another service
      • evilaliv3 joined the channel
      • daniele_athome has quit
      • daniele_athome joined the channel
      • clokep joined the channel
      • efphe has quit
      • daniele_athome has quit
      • daniele_athome joined the channel
      • efphe joined the channel
      • daniele_athome has quit
      • jstanley_ has quit
      • }ls{ joined the channel
      • __marco has quit
      • jstanley joined the channel
      • tenth joined the channel
      • terrycojones joined the channel
      • wbh joined the channel
      • wbh
        How would a server make a request to another server, to receive a value for one of its configuration variable? The request value would start out as a deferred, right? How do you store it in a configuration variable somewhere, and not run anything that depends on it before it is ready? Should the server be using an external requests library (like requests) rather than agent.request?
      • asdf
        wbh, treq is useful, but just using Agent is fine too; you mean the remote server speaks HTTP?
      • if so then sure, use Agent, or the getPage shortcut (or better yet, treq)
      • wbh
        asdf: http to remote server, yes. The results seem to be deferreds, I do not understand how to store a result rather than immediately use it with a callback.
      • asdf
        write a callback that will then store it somewhere
      • wbh
        asdf: something along the lines of __setattr__ ? And return with an error anywhere it is used before being defined?
      • Well for a lambda at least I realize a normal function with normal assignment is equivalent.
      • asdf
        wbh, depends, how do you want to use it afterwards? but sure, `def set_it(result): myobject.thing = result;; d.addCallback(set_it)`
      • terrycojones has quit
      • wbh, maybe show some code?
      • wbh
        asdf: I can try to find the part again. I think I see now, though. Doing an assignment in a callback, and error handling if it has been unassigned an is attempted used, is the normal
      • method for doing this?
      • asdf
        it very much depends; hang on, lemme write an example or two
      • wbh
        I was confused since all the examples I could find of deferreds just immediately print it or pass it to another function, and I could not find any examples of the return value being stored for later use.
      • asdf
        so the basic pattern we're looking at is this, right: https://gist.github.com/tehasdf/0662bfea4850406...
      • so whenever you need the data, you just go get it
      • but this is obviously bad because there's no caching and you do 123 requests if you need the data 123 times
      • terrycojones joined the channel
      • so you might want to implement a pattern like this (but this is actually wrong): https://gist.github.com/tehasdf/0662bfea4850406...
      • wbh
        asdf: so what dose yield on a deferred (with @inlinecallbacks) result in?
      • is it a shorter way of doing mything.data = result as a callback to the deferred?
      • asdf
        well right, the `yield` will only resume execution after the deferred it's yielding has fired
      • wbh
        I see. That is the functionality I was searching for. Thanks.
      • asdf
        no, that's not done yet
      • you'll see in a second
      • wbh
        ohh
      • asdf
      • so the problem with this is, it only sets ._cached after it fetches
      • in caching that's called a "thundering herd" problem
      • wbh
        should use_something be returning data?
      • nowait right.
      • yield
      • asdf
        well it's just the example function that calls the get_data
      • and get_data is the part that would fetch http
      • so anyway, it's cached wrong, because if get_data was called several times concurrently, it'll fire several requests
      • as opposed to just firing one request and returning the same data to each call
      • so the easiest way to fix that, is to just use DeferredSemaphore
      • so we define a DeferredSemaphore with tokens=1 so it'll only allow one .run() at a time, and the others will wait
      • uh i know it's a bit hard to get at first but just bear with me here :)
      • wbh
        the problem being the case where the concurrent calls happen before a cached result is available?
      • terrycojones has quit
      • asdf
        right, and the last example fixes that, because when you use semaphore like that, only one _do_get at a time can run
      • so, let's say you call .get_data() more than once, only one call goes through to _do_get, and the rest wait on the semaphore
      • the first call finishes and sets ._cached
      • now the next call runs, and immediately returns ._cached
      • and btw we return succeed(_cached) so as to make _do_get always return a deferred, so the interface is always the same
      • and btw 2, `semaphore.run(f, 1, 2, 3)` -> `f(1, 2, 3)` (you need to pass args separately like that, because otherwise it'd just call the function right there)
      • __marco joined the channel
      • wbh
        serve_data serves as a dummy function to simulate a remote server, right?
      • asdf
        right
      • robbyoconnor joined the channel
      • robbyoconnor has quit
      • wbh
        If the use case was to receive a configuration value from the remote server, a straightforward way would be to assign data to some attribute in use_something? It seems main returns a deferred.