#twisted

/

      • licensed joined the channel
      • faldridg_ joined the channel
      • faldridge has quit
      • uda has quit
      • faldridg_ has quit
      • uda joined the channel
      • rajesh joined the channel
      • clokep has quit
      • garetjax joined the channel
      • dawuud has quit
      • garetjax has quit
      • garetjax joined the channel
      • garetjax has quit
      • garetjax_ joined the channel
      • faldridge joined the channel
      • faldridge has quit
      • adamdangoor has quit
      • runciter has quit
      • garetjax_ has quit
      • rajesh has quit
      • licensed has quit
      • dude-x joined the channel
      • dude-x has quit
      • faldridge joined the channel
      • faldridge has quit
      • runciter joined the channel
      • terrycojones joined the channel
      • terrycojones has quit
      • dude-x_ joined the channel
      • clajo04 joined the channel
      • eydenbarboza joined the channel
      • eydenbarboza has quit
      • Darkman802_ joined the channel
      • Darkman802 has quit
      • runciter has quit
      • Hasimir has quit
      • Khayman joined the channel
      • Khayman is now known as Hasimir
      • dude-x__ joined the channel
      • dude-x_ has quit
      • Hodgestar has quit
      • lifeless joined the channel
      • Hodgestar joined the channel
      • jamesaxl joined the channel
      • terrycojones joined the channel
      • terrycojones has quit
      • terrycojones joined the channel
      • slav0nic joined the channel
      • jordanl has quit
      • efphe joined the channel
      • terrycojones has quit
      • garetjax joined the channel
      • terrycojones joined the channel
      • brodolfo joined the channel
      • terrycojones has quit
      • terrycojones joined the channel
      • terrycojones has quit
      • b3h3m0th joined the channel
      • faldridge joined the channel
      • faldridge has quit
      • clokep joined the channel
      • Frantic joined the channel
      • Frantic
        Hey guys, I'm running a Flask webapp using twisted, and I now want to daemonize the process. So I'm trying to use the daemonize PyPI package, which does the common things (forks, sets fd 0/1/2 to /dev/null, etc), however my reactor crashes when daemonized, it tries to close an invalid file descriptor which is just some python file that was read earlier.
      • The whole thing is baffling, the file descriptor was it reading some random .py file while importing modules, but that was closed previously by python (once it finished reading it I suppose) and now twisted tries to do something with it and I have no idea what's wrong
      • Could someone please point me the right way? I'm a bit lost
      • tos9
        Frantic: Why do you want to daemonize?
      • Frantic
        tos9: I'm trying to deamonize the run function shown here: https://gist.github.com/anonymous/514d3a7907fe4...
      • tos9
        Frantic: Yes but *why* do you want to daemonize :)?
      • Frantic: The right way generally is not to daemonize.
      • Juhaz
        and why do you want to do it using some third party tool instead of using twistd?
      • tos9
        And to just use `twistd -n web`, or the newer `twist web`
      • Frantic
        tos9: I know, but my company's ops requires that something they manage detach from the terminal and daemonize
      • clokep has quit
      • Juhaz: I don't know what you mean by "using twistd"
      • tos9: I mean, if it were up to me, I would have it not detach and use a process manager such as supervisord or something, but it's not up to me in this case
      • tos9
        That sounds like quite a silly thing if they require every process to implement daemonization and not use any process managers :P
      • But yes, OK, if you do need to, just use twistd web
      • `twistd web --wsgi myapp.app` is a daemonizing WSGI container.
      • Frantic
        tos9: I have used twistd before for that, but in this case I need to do a bit of setup beforehand, for example I need to grab some info from commandline, read some config from file, etc. I suppose I could use twistd but need to figure out a way of using it from the python app
      • tos9
        Frantic: That is what you do in myapp.app.
      • Or in a twistd plugin if you'd like.
      • Frantic
        tos9: But I don't know the port for example until after I run my config code
      • I could technically have the main python script os.system('twistd ...') but that would be hacky
      • So I'm trying to find a way of daemonizing just like twistd does
      • Juhaz
        the config code would be in the twistd plugin
      • or be ran by it
      • Frantic
        Juhaz: correct me if I'm wrong, but doesn't `twistd web` take the --port option? If so, how can my module later define the port?
      • BTW, I'm not very experienced with twisted, so please tell me if my assumptions are wrong
      • I suppose what I'd like is: Given a function that configures a reactor, what's the best way to daemonize that and run the reactor
      • Juhaz
        ah, yeah, I guess "web" is the plugin in that case.
      • Frantic
        I don't follow
      • Juhaz
        I mean web is a twistd plugin, but since it's a ready-made one it won't run your code, I was thinking of self created plugins.
      • Frantic
        yes, I'm digging through the twisted.web code, but it's a bit hard to figure out what's going on there
      • tos9: I've found what you meant by doing it 'in a twisted plugin', but that means my runner needs to be managed by twistd. My app needs to run in two modes: 1) Local test run, and 2) Managed daemon run. I need to use my own runner (e.g. argparser, etc) for option 1)
      • faldridge joined the channel
      • clokep joined the channel
      • OK, I've stopped using the python-daemonize package and instead wrote my own small daemonize function which does the expected things, and the twisted reactor is no longer crashing
      • I still have no idea what was casing the weird crash though, but whatever, I've spent so much time reading up on this that I've learned what daemonizing needs to be exactly
      • faldridge has quit
      • faldridge joined the channel
      • thanks for the ideas guys
      • runciter joined the channel
      • tonythomas joined the channel
      • faldridge has quit
      • faldridge joined the channel
      • LionsMane joined the channel
      • faldridge has quit
      • rajesh joined the channel
      • kenaan
        new core enhancement https://tm.tl/#8842 by Stibbons: Readers/Writer Deferred Lock
      • tomprince has quit
      • rajesh has quit
      • terrycojones joined the channel
      • runciter has quit
      • calston_ is now known as calston
      • tomprince joined the channel
      • terrycojones has quit
      • frode_ joined the channel
      • runciter joined the channel
      • InfoTest joined the channel
      • dude-x joined the channel
      • slav0nic has quit
      • faldridge joined the channel
      • runciter_ joined the channel
      • efphe has quit
      • runciter has quit
      • runciter_ is now known as runciter
      • slav0nic joined the channel
      • faldridge has quit
      • rajesh joined the channel
      • runciter has quit
      • faldridge joined the channel
      • rajesh has quit
      • faldridge has quit
      • faldridge joined the channel
      • faldridge has quit
      • iffy joined the channel
      • iffy has left the channel
      • faldridge joined the channel
      • faldridge has quit
      • LionsMane has quit
      • Vaelatern has quit
      • terrycojones joined the channel
      • Vaelatern joined the channel
      • iffy1 joined the channel
      • iffy1 has left the channel
      • jordanl joined the channel
      • LionsMane joined the channel
      • garetjax has quit
      • garetjax joined the channel