#jython IRC Log (v0.9)


IRC Log for 2013-10-21

Timestamps are in GMT/BST.

[0:18] * sinistersnare is now known as sinsnare|away
[2:31] * lheuer (~Adium@unaffiliated/lheuer) Quit (Quit: Leaving.)
[4:32] <jimbaker> i pushed up support for large collection literals
[4:32] <jimbaker> into jython trunk
[4:45] * sinsnare|away (6c1c5d99@gateway/web/cgi-irc/kiwiirc.com/ip. Quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
[4:45] * sinistersnare (6c1c5d99@gateway/web/cgi-irc/kiwiirc.com/ip. has joined #jython
[4:54] * sinistersnare (6c1c5d99@gateway/web/cgi-irc/kiwiirc.com/ip. Quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
[4:55] * sinistersnare (6c1c5d99@gateway/web/cgi-irc/kiwiirc.com/ip. has joined #jython
[6:32] * lheuer (~Adium@f049140197.adsl.alicedsl.de) has joined #jython
[6:32] * lheuer (~Adium@f049140197.adsl.alicedsl.de) Quit (Changing host)
[6:32] * lheuer (~Adium@unaffiliated/lheuer) has joined #jython
[6:34] * lheuer (~Adium@unaffiliated/lheuer) Quit (Client Quit)
[6:38] * lheuer (~Adium@f049140197.adsl.alicedsl.de) has joined #jython
[6:38] * lheuer (~Adium@f049140197.adsl.alicedsl.de) Quit (Changing host)
[6:38] * lheuer (~Adium@unaffiliated/lheuer) has joined #jython
[7:44] * vIkSiT (~vIkSiT|2@unaffiliated/viksit) has joined #jython
[8:20] * vIkSiT (~vIkSiT|2@unaffiliated/viksit) Quit (Quit: This computer has gone to sleep)
[12:07] * r0bby_ (~wakawaka@guifications/user/r0bby) Quit (Ping timeout: 248 seconds)
[12:23] <topi`> cool!
[12:23] <topi`> we're getting progress on things like Requests, I'll check that out :)
[12:25] <topi`> my inexperience with Java is troubling me. If I have jython executing code like this:
[12:25] <topi`> url = java.net.URL(addr)
[12:25] <topi`> conn = url.openConnection()
[12:25] <topi`> br = java.io.BufferedReader( java.io.InputStreamReader(conn.getInputStream()))
[12:25] <topi`> is it so that I have to close that conn, and/or that br ? Something here is eating up tomcat's FD's.
[12:26] <topi`> it just occurred to me that since I'm calling java functions, Jython might not be as nice to me as CPython and clean everything up after the interpreter leaves the scope.
[12:56] <peke> topi`: my experience is that jython/java is very slow to release resources like that. with cpython that's fast because refcounting gc cleans up garbage so fast. totally different in jvm.
[12:57] <peke> you definitely should close those connections/streams explicitly.
[12:57] <peke> notice that in some cases java will automatically close the underlying stream, thoug. apidocs ought to tell when that's the case.
[12:58] <peke> this might be a very good use case for contextlib.closing: http://docs.python.org/2/library/contextlib.html#contextlib.closing
[13:06] <peke> related to this, python code that expects __del__ to be called when an object is not referenced anymore is likely not to work with jython.
[13:06] <peke> for example, running the code below as a script prints 'bye' in cpython but nothing with jython
[13:07] <peke> class Del(object):
[13:07] <peke> def __del__(self):
[13:07] <peke> print 'bye'
[13:07] <peke> Del()
[13:38] * Scorp1us (~Scorp1us@75-145-94-105-WashingtonDC.hfc.comcastbusiness.net) has joined #jython
[13:43] * mcurve (~quassel@pop.nakinasystems.com) Quit (Remote host closed the connection)
[13:44] * mcurve (~quassel@pop.nakinasystems.com) has joined #jython
[14:07] * zz_whg is now known as whg
[14:38] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[14:48] * r0bby_ (~wakawaka@guifications/user/r0bby) has joined #jython
[14:49] * robbyoconnor (~wakawaka@guifications/user/r0bby) has joined #jython
[14:49] * r0bby_ (~wakawaka@guifications/user/r0bby) Quit (Read error: Connection reset by peer)
[15:03] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Max SendQ exceeded)
[15:04] * robbyoconnor (~wakawaka@guifications/user/r0bby) has joined #jython
[15:04] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Client Quit)
[15:17] * xymox (lechuck@unaffiliated/contempt) Quit (Ping timeout: 245 seconds)
[15:23] <jimbaker> contexlib.closing is good. but it occurs to me that if a class implements java.lang.AutoCloseable, maybe we should add corresponding context manager (__enter__, __exit__) automatically
[15:24] <jimbaker> of course that would require java 7 :)
[15:27] * vIkSiT (~vIkSiT|2@unaffiliated/viksit) has joined #jython
[15:28] * vIkSiT (~vIkSiT|2@unaffiliated/viksit) Quit (Client Quit)
[15:42] <jimbaker> topi`, here's one example of where i have used contextlib.closing: https://github.com/jythontools/clamp/blob/master/clamp/build.py#L297
[15:49] <jimbaker> now that pip trunk uses requests, i guess jython beta 2 will support both. i'm going to fix idna encoding next, which should be fast
[16:02] * whg is now known as zz_whg
[16:04] * zz_whg is now known as whg
[16:28] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) Quit (Quit: enebo)
[16:30] * xymox (lechuck@unaffiliated/contempt) has joined #jython
[16:32] * Arfrever (~Arfrever@apache/committer/Arfrever) has joined #jython
[16:46] * srcerer_ is now known as srcerer
[17:07] * vIkSiT (~vIkSiT|2@unaffiliated/viksit) has joined #jython
[17:13] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[17:36] * lheuer1 (~Adium@g228224202.adsl.alicedsl.de) has joined #jython
[17:39] * lheuer (~Adium@unaffiliated/lheuer) Quit (Ping timeout: 256 seconds)
[17:53] * lheuer1 is now known as lheuer
[17:53] * lheuer (~Adium@g228224202.adsl.alicedsl.de) Quit (Changing host)
[17:53] * lheuer (~Adium@unaffiliated/lheuer) has joined #jython
[18:55] <vIkSiT> hello all
[18:55] <vIkSiT> what would be the best way for me to package a python app into a jar file?
[18:56] <vIkSiT> I know the django-jython project can give me a WAR but it puts everything as .class within the war
[19:05] * paolo (~Paolo@net-2-36-97-216.cust.dsl.vodafone.it) has joined #jython
[19:05] * agronholm (~agronholm@2001:1bc8:102:6f29:806:c4bd:c633:23b6) Quit (Ping timeout: 264 seconds)
[19:09] * agronholm (~agronholm@2001:1bc8:102:6f29:45c:50f5:7c99:7b48) has joined #jython
[19:09] * ChanServ sets mode +o agronholm
[19:25] <sinistersnare> vIkSiT: check jythontools/clamp on github, along with jimbaker/clamped for an example
[19:30] <vIkSiT> sinistersnare, aha thanks. how production quality is this? :)
[19:31] <vIkSiT> hmm, so heres what i'm trying to do.
[19:31] <vIkSiT> I have a django application. I want to bundle it, and import it into an existing java program
[19:32] <vIkSiT> so far, I bundled the WAR file, took the .class files out of it, put into my classpath. Works with jython, trying to make it work with a java program
[19:33] <vIkSiT> (also, if jimbaker is around, has ideas)
[19:36] <topi`> vIkSiT: interesting requirements... but why would you want to bundle django within a java program? instead of letting tomcat handle it...
[19:38] <topi`> vIkSiT: my django requirements are easier... I just need a background thread that collects information and is packaged into the *same* war that has the django app.
[19:38] <topi`> that's done using a small servlet that spawns a thread, and from within that thread, my Python class is called (using clamp, of course)
[19:39] <vIkSiT> topi`, primarily because I'm using a NIO framework
[19:39] <vIkSiT> hmm
[19:40] <topi`> oh, interesting
[19:40] <topi`> I don't know much about that. Isn't Play a NIO framework?
[19:40] <vIkSiT> topi`, I'm using the play framework - I'm not sure if putting it within Tomcat/Jetty will allow tha model
[19:40] <vIkSiT> yeap
[19:41] <vIkSiT> my design was something like - get django bundled into a jar, import it and then route play routing -> django view
[19:41] <topi`> why do people choose it? I guess it's slightly different from other, more regular approaches.
[19:41] <vIkSiT> topi`, well, async requirements. Long calls to services in the background. That means you don't have a threadpool waiting to handle requests
[19:41] <topi`> I guess you could also set up Apache or Varnish to do such routing
[19:41] <vIkSiT> you just handle it, give it to async
[19:42] <vIkSiT> yes, the main point is to start porting the django code into play :) but staged..
[19:42] <topi`> yeah, threadpools are boring, async gives you less worries
[19:42] <topi`> that's why I implement many (not all) projects in Twisted :)
[19:43] <vIkSiT> topi`, hehe, I've used gunicorn with eventlets..
[19:43] <vIkSiT> but c heritage there
[19:44] <topi`> vIkSiT: you should note that the default Django setup is to use WSGI (hence you'd need to implement WSGI in your java code)
[19:44] <topi`> take a look at the application.py that is bundled in top level when you create war with manage.py war
[19:46] <vIkSiT> topi`, correct - i was wondering if that's even needed, since I was planning to wrap an incoming play request into a Jython DjangoHttpRequest object
[19:46] <vIkSiT> and then just call views.myfunction(request)
[19:46] <vIkSiT> from within java
[19:47] <jimbaker> play integration w/ jython would be interesting??? does play support the standard Servlet API
[19:47] <jimbaker> ?
[19:47] <vIkSiT> no, play isn't built on top of servlets..
[19:47] <vIkSiT> http://stackoverflow.com/questions/6628927/why-is-the-play-framework-not-built-on-top-of-the-servlet-api
[19:48] <vIkSiT> play follows the django/rails approach in terms of non container, bundled webserver..
[19:48] <jimbaker> ok, then you should take a look at the modjy implementation. it's pretty short, i'm sure it would be easy to create a similar wsgi adapter to play
[19:48] <jimbaker> re clamp - it's definitely alpha right now
[19:49] <jimbaker> in part because the API is not necessarily stable yet
[19:50] <vIkSiT> jimbaker, ah got it, will do.
[19:50] <jimbaker> i definitely recommend playing w/ it because i expect this will be the standard way to support such packaging. btu at the same time it's in https://github.com/jythontools for a reason...
[19:50] <vIkSiT> ah I see.
[19:51] <jimbaker> the other real thing i need to do is backfill testing. i really needed to spike this because i wasn't familiar w/ the relevant codebases. i think the code is in good shape and *it works for me* but i really want solid testing on it before it goes to beta
[19:52] <jimbaker> vIkSiT, btw, large collection literals landed last night in jython trunk - and also pulled into jython-ssl
[19:52] <vIkSiT> sweet
[19:52] <vIkSiT> thats pretty awesome :)
[19:52] <vIkSiT> btw, modjy seems part of jython now.
[19:53] <vIkSiT> so, its standard in terms of support/production quality etc?
[19:54] <jimbaker> vIkSiT, one can now do this in jython: eval("(" + ",\n".join((str(x) for x in xrange(64000))) +")")
[19:54] <jimbaker> vIkSiT, not certain what you're describing as being standard...
[19:55] <vIkSiT> jimbaker, ah, my question is a bit vague sorry. can you tell me where i can find the modjy code itself?
[19:55] <vIkSiT> bitbucket find is a bit .. hard
[19:56] <jimbaker> vIkSiT, it's part of jython itself???https://bitbucket.org/jython/jython/src/8e75d288ef3283e18f279e5da81671771b0a9516/src/com/xhaus/modjy?at=default
[19:58] <vIkSiT> aah src/com/xhaus
[19:58] <vIkSiT> didnt look into xhaus.. thanks
[19:59] <jimbaker> vIkSiT, we probably should have merged it in differently, but alan donated it as-is
[20:00] <jimbaker> as of 2.7 beta 2, i expect that such packages would be on pypi anyway
[20:01] * jimbaker needs to add explicit support for bundled jars to clamp :)
[20:16] * thereisnospoon_ (~thereisno@27-33-1-87.tpgi.com.au) has joined #jython
[20:16] <vIkSiT> hehe
[20:18] * thereisnospoon (~thereisno@27-33-1-87.tpgi.com.au) Quit (Ping timeout: 248 seconds)
[20:28] <vIkSiT> jimbaker, here's a question. i used the django-jython project to generate a django war file. and i have a bunch of .class files. If I write a simple java program that imports module.myfile from module/myfile.py_class, shouldn't a simple java -cp /path/to/module JavaFile just work?
[20:29] <jimbaker> vIkSiT, sorry, i'm not understanding this question
[20:29] * paolo (~Paolo@net-2-36-97-216.cust.dsl.vodafone.it) Quit (Quit: Leaving)
[20:30] * paolo (~Paolo@net-2-36-97-216.cust.dsl.vodafone.it) has joined #jython
[20:31] * paolo (~Paolo@net-2-36-97-216.cust.dsl.vodafone.it) Quit (Client Quit)
[20:43] <sinistersnare> sorry i was gone :p GF came over :p
[21:31] <topi`> vIkSiT: you should need the PythonInterpreter, those .class files alone won't suffice (remember, python is a dynamically typed language)
[21:32] <topi`> also, if you look closely at what clamp is doing, it is actually embedding a PythonInterpreter into your project that you're clamping
[21:32] * sinistersnare is now known as sinsnare|away
[21:32] * Arfrever (~Arfrever@apache/committer/Arfrever) Quit (Ping timeout: 240 seconds)
[21:33] <topi`> what is interesting is the small amount of effort (having __proxymaker__ in your python class and doing buildjar) to actually be able to import your Python classes into java projects
[21:34] <topi`> it's never been easier than this!
[21:34] * whg is now known as zz_whg
[21:43] * xymox (lechuck@unaffiliated/contempt) Quit (Ping timeout: 265 seconds)
[21:59] <vIkSiT> topi`, ah exactly, i think that was what i was missing
[22:00] <vIkSiT> thanks for the insight
[22:00] <vIkSiT> topi`, have you used django with clamp?
[22:00] <vIkSiT> jimbaker, topi` just answered my question.
[22:00] <vIkSiT> so basically, here are my two options
[22:01] <vIkSiT> - use clamp with django, generate a jar, import it into my web framework and then route urls into individiual django functions
[22:01] <vIkSiT> - implement a modjy style interface that basically converts a play framework request into what django/wsgi expects
[22:01] <vIkSiT> and then somehow make django talk to it (not sure how exactly)
[22:02] <vIkSiT> jimbaker, topi` - comments on a better approach for what i'm trying to do?
[22:14] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) Quit (Quit: enebo)
[22:30] * enebo (~enebo@c-75-73-8-169.hsd1.mn.comcast.net) has joined #jython
[22:32] <vIkSiT> jimbaker, clamp question. can it be used for pure functions/modules?
[22:33] <vIkSiT> or does it assume classes?
[22:35] * robbyoconnor (~wakawaka@guifications/user/r0bby) has joined #jython
[22:52] * robbyoconnor (~wakawaka@guifications/user/r0bby) Quit (Ping timeout: 248 seconds)
[23:02] <jimbaker> vIkSiT, the idea of clamp is that you're pulling python into the java objec tmodel
[23:02] <jimbaker> so there's no such thing as a standalone function in java, or even a module
[23:03] <vIkSiT> jimbaker, ah thanks for the info. In my case..
[23:03] <jimbaker> so your clamped classes must implement java interfaces and/or extend a java class
[23:03] <vIkSiT> I see
[23:03] <jimbaker> that's how java "knows" how to work w/ this class
[23:03] <vIkSiT> jimbaker, trying to figure this out for the likes of django.
[23:04] <vIkSiT> where each python file is just a collection of functions
[23:04] <jimbaker> btw, PythonInterpreter is not actually used, but that's a minor nit
[23:04] <jimbaker> just a PySystemState
[23:04] <vIkSiT> so there's no object framework to actually implement against
[23:04] <vIkSiT> (ah I see)
[23:05] <jimbaker> so if you need to have java directly import python classes, that's the primary functionality of clmap
[23:05] <jimbaker> but i also added packaging support, so presumably WARs at some point can be built using clamp. but i'd have to look at django-jython to see exactly what that means
[23:07] <vIkSiT> hmm
[23:07] <vIkSiT> right. so django-jython goes in, and converts a directory of python files to a series of class files
[23:07] <vIkSiT> views.py becomes views$py.class
[23:07] <vIkSiT> and then it bundles two directories into the war
[23:07] <vIkSiT> lib/ which contains deps
[23:07] <jimbaker> through compileall
[23:07] <vIkSiT> and lib-python/ which contains all class files from the python world - django, your app, etc
[23:08] <vIkSiT> so I thought I'd take this lib-python directory
[23:08] <vIkSiT> and try to import
[23:08] <vIkSiT> ./simple/views$py.class: warning: Cannot find annotation method 'value()' in type 'org.python.compiler.APIVersion': class file for org.python.compiler.APIVersion not found
[23:08] <vIkSiT> cannot access org.python.core.PyFunctionTable
[23:08] <vIkSiT> etc
[23:08] <vIkSiT> so obviously that wont' work without the PySystemState/Interpreter objects
[23:09] <jimbaker> yeah, clamp solves this problem
[23:09] <jimbaker> note the layout is different
[23:09] <vIkSiT> now I'm thinking about - either I implement my django views with some sort of class heirarchy
[23:09] <jimbaker> i'm sure we can readily reconcile
[23:09] <jimbaker> basically i followed the layout that singlejar wants
[23:09] <vIkSiT> and let it implement not just django classes, btu also clampproxymaker
[23:09] <vIkSiT> ah
[23:12] <jimbaker> yes, that does make sense
[23:12] <jimbaker> i don't see why you shouldn't be able to do both
[23:13] <jimbaker> as long as they are java interfaces, just mix in as makes sense
[23:13] <jimbaker> maybe do some metaclass stuff
[23:13] <vIkSiT> how do you mean metaclass stuff?
[23:14] <vIkSiT> jimbaker, have you ever looked at django-jython btw?
[23:15] <jimbaker> vIkSiT, i kicked the project off, so yes :)
[23:15] <vIkSiT> oh hehe
[23:15] <jimbaker> but i haven't looked at it for several years.
[23:18] <jimbaker> http://www.youtube.com/watch?v=UgIk_bx_5h4 is probably the last time i thought about the war file support
[23:19] <vIkSiT> ah :)
[23:19] <jimbaker> i'm somewhat fatter in that video i see. now i run on a regular basis, so that part of me has changed
[23:20] <vIkSiT> haha as long as youre going the other way, its all good
[23:21] <vIkSiT> jimbaker, so whats your perspective on my django-java integration story?
[23:21] <vIkSiT> java aka NIO based play framework talking to django, with code sharing
[23:21] <jimbaker> ironically, the fact that i run is in part due to such python people as jacob kaplan moss - we have all lost weight since then
[23:21] <vIkSiT> aha :)
[23:21] <vIkSiT> i'm not a runner, but i like to bike.
[23:21] <jimbaker> vIkSiT, i think it's pretty awesome
[23:22] <jimbaker> also the biking. today i ran 5 miles and biked 10
[23:22] <vIkSiT> the cycling or the integration? :P
[23:22] <sinsnare|away> yes.
[23:22] * sinsnare|away is now known as sinistersnare
[23:23] <jimbaker> so NIO, yes, this makes perfect sense. django should just run on it, you just need to have a wsgi adapter for this purpose
[23:23] <sinistersnare> is jython gonna do Google Summer of Code? or google code in? (im gonna be in the GCI, perks of being a high schooler i guess :p)
[23:23] <jimbaker> sinistersnare, i guess if we have some interested smart students :)
[23:24] <jimbaker> if i mentor, it must be after dec 20
[23:24] <vIkSiT> jimbaker, ah. could you expand on the WSGI adapter portion of it? I haven't done much work in the adapter area itself
[23:24] <vIkSiT> what would you suggest looking at for more information?
[23:24] <sinistersnare> :D GCI starts in like Nov14 though and ends like at the end of january
[23:24] <jimbaker> because i am not taking anything else on like this until after i have finished grading my univ course
[23:25] <jimbaker> sinistersnare, ahh. yes, you need to find a willing mentor. pjenvey and fwierzbicki1 have both done this. others might volunteer
[23:26] <jimbaker> otherwise i would love to do this
[23:26] <sinistersnare> january 20 is like it
[23:26] <vIkSiT> I have a couple of questions on that. If I understand correctly, build something like modjy does on top of play/nio. Question is - how do I plug django into it?
[23:26] <jimbaker> vIkSiT, iirc, wsgi is a very simple interface
[23:27] <jimbaker> so mapping to play should be doable. but i haven't researched. i'm saying doable as in "at the 30000' level"
[23:27] <vIkSiT> right. so lets say a nio/wsgi interface into play is built that can run any wsgi compatible code (django or otherwise)..
[23:27] <vIkSiT> how would one include the jython-django code into this?
[23:27] <sinistersnare> and the mentor application period ends in like 6 days :(
[23:28] <jimbaker> yes, that would be pretty damn awesome
[23:28] <vIkSiT> deploy a war etc
[23:28] <jimbaker> vIkSiT, sure, you do need to see how your container wants to deploy
[23:29] <jimbaker> sinistersnare, i really encourage you to reach out on jython-dev mailing list
[23:29] <vIkSiT> jimbaker, thats the thing I'm missing I think. Given play doesn't deploy on an existing container, instead it starts up a server on some port (embedded netty) - it doesn't actually have any "container style deployments"
[23:30] <jimbaker> vIkSiT, ok, but you can always do some sort of classloader thing
[23:30] <jimbaker> effectively that's what a container is, plus associated resources like connection pools
[23:30] <jimbaker> from the contained app's perspective
[23:31] <sinistersnare> that sounds good, ill email the mailing list
[23:31] <jimbaker> sinistersnare, cool. i'm happy to help guide here, so there's that
[23:31] <vIkSiT> jimbaker, got it. and then, you're saying that write the django code using clamped such that it can be loaded into this classloader mechanism?
[23:31] <vIkSiT> or does that mean clamp isn't needed anymore?
[23:31] <jimbaker> but mentoring tends to be somewhat more involved. or it should be ;)
[23:32] <jimbaker> well, you want to use clamp packaging in all likelihood
[23:32] <jimbaker> because really no one should have to do this setuptools integration more than once
[23:33] <vIkSiT> I see. another related question - lets say I have a django app that contains only one views file, and everything else as modules. Do *all* functions/classes need to be wrapped with clamp?
[23:33] <sinistersnare> ok im subscribing with jython-dev (im only on jython-users apparently :p)
[23:33] <jimbaker> it's also possible that clamp proxymaker support could greatly simplify the integration point
[23:33] <vIkSiT> or just the ones tha are directly imported into java?
[23:34] <jimbaker> vIkSiT, i'm just thinking you could get some mileage out of the direct import into java. as in, minimizing managing the entry points
[23:34] <jimbaker> in terms of what you have to write on the
[23:34] <jimbaker> play side
[23:35] <jimbaker> again, that's 9144 meter level
[23:37] <jimbaker> anyway, modjy is 247 lines. so i expect the play integration to be something similar
[23:38] <vIkSiT> hmm true
[23:59] <sinistersnare> https://docs.google.com/document/d/195lKRmXhSiH5cNfn3N8ctquCk4UIiEFuRN5-ZvvWhO4/edit?usp=sharing jimbaker does this seem good?


These logs were automatically created by JythonLogBot_ on irc.freenode.net using a slightly modified version of the Java IRC LogBot (github).