Giter Site home page Giter Site logo

mod-lang-jython's People

Contributors

aaboyd avatar blalor avatar darylteo avatar figroc avatar fregaham avatar jasonparekh avatar jdonnerstag avatar jenslaufer avatar julien3 avatar kuujo avatar npahucki avatar pidster avatar purplefox avatar vietj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mod-lang-jython's Issues

sock.js bridge hook doesn't work

Using io.vertxlang-jython2.1.1, the EventBusBridge hook doesn't seem to work.

The problem seems to be in src/main/api_shim/core/sock_js.py

self.java_obj.setHook must be called before the 'bridge' call, as the bridge is created with the currently set hook.

also, EventBusBridge init method is probably wrong, as bridge_with_config calls it with a reference to "hook", while the EventBusBridge expects j_bridge and creates a new _EventBusBridgeHook

reproducer:

index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Hello</title>
    <script src="http://cdn.sockjs.org/sockjs-0.3.4.min.js"></script>
    <script src='vertxbus-2.1.js'></script>
<script>
    var eb = new vertx.EventBus('http://localhost:8080/eventbus');
    eb.onopen = function() {
      eb.registerHandler('some-address', function(message) {
        console.log('received a message: ' + JSON.stringify(message));
      });
    }
</script>
</head>
<body>
</body>
</html>

server.py

import functools
import vertx
from core.event_bus import EventBus

server = vertx.create_http_server()

@server.request_handler
def request_handler(req):
    file = ''
    if req.path == '/':
        file = 'index.html'
    elif '..' not in req.path:
        file = req.path[1:]
    req.response.send_file(file)

sockJSServer = vertx.create_sockjs_server(server)
bridge = sockJSServer.bridge({'prefix' : '/eventbus'},
    [],
    [])

@bridge.socket_created_handler
def socket_created_handler(socket):
    print "socket created"

server.listen(8080, 'localhost')

also, vertxbus-2.1.js must be present.

Tried with vert.x-2.1RC3

Lacking support for lists on the event bus

The Jython event bus lacks support for sending lists on the event bus. The core API supports JsonArray, so the Jython event bus should support the Python equivalent. This is a bug.

I'll try to get this ready for Vert.x 2.1 tonight :-)

set_expect_multipart not working

My code to handle a post request

__author__ = 'chanhlt'

import vertx
from core.http import RouteMatcher

logger = vertx.logger()

rm = RouteMatcher()


def auctions_handler(req):
    req.set_expect_multipart(True)

    @req.end_handler
    def end_handler():
        print 'multi part %s' % req.is_expect_multipart()
        attrs = req.form_attributes()
        print attrs


rm.all_re("/auction/", auctions_handler)

vertx.create_http_server().request_handler(rm).listen(8080)

Error

vertx run app.py
Succeeded in deploying verticle
multi part True
Exception in Python verticle
java.lang.IllegalStateException: Call expectMultiPart(true) before request body is received to receive form attributes
    at org.vertx.java.core.http.impl.DefaultHttpServerRequest.formAttributes(DefaultHttpServerRequest.java:251)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
    at org.python.core.PyObject.__call__(PyObject.java:387)
    at org.python.core.PyObject.__call__(PyObject.java:391)
    at org.python.core.PyMethod.__call__(PyMethod.java:109)
    at core.http$py.form_attributes$79(__pyclasspath__/core/http.py:684)
    at core.http$py.call_function(__pyclasspath__/core/http.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
    at org.python.core.PyFunction.__call__(PyFunction.java:317)
    at org.python.core.PyFunction.__call__(PyFunction.java:312)
    at org.python.core.PyProperty.property___get__(PyProperty.java:69)
    at org.python.core.PyProperty.__get__(PyProperty.java:58)
    at org.python.core.PyObject.object___findattr__(PyObject.java:3706)
    at org.python.core.Deriveds.__findattr_ex__(Deriveds.java:42)
    at org.python.core.PyObjectDerived.__findattr_ex__(PyObjectDerived.java:983)
    at org.python.core.PyObject.__getattr__(PyObject.java:923)
    at org.python.pycode._pyx0.end_handler$3(app.py:34)
    at org.python.pycode._pyx0.call_function(app.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyBaseCode.call(PyBaseCode.java:120)
    at org.python.core.PyFunction.__call__(PyFunction.java:307)
    at core.handlers$py.handle$6(__pyclasspath__/core/handlers.py:41)
    at core.handlers$py.call_function(__pyclasspath__/core/handlers.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
    at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
    at org.python.core.PyFunction.__call__(PyFunction.java:387)
    at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
    at org.python.core.PyMethod.__call__(PyMethod.java:211)
    at org.python.core.PyMethod.__call__(PyMethod.java:201)
    at org.python.core.PyMethod.__call__(PyMethod.java:196)
    at org.python.core.PyObject._jcallexc(PyObject.java:3502)
    at org.python.core.PyObject._jcall(PyObject.java:3534)
    at org.python.proxies.core.handlers$NullDoneHandler$1.handle(Unknown Source)
    at org.vertx.java.core.http.impl.DefaultHttpServerRequest.handleEnd(DefaultHttpServerRequest.java:314)
    at org.vertx.java.core.http.impl.ServerConnection.handleEnd(ServerConnection.java:209)
    at org.vertx.java.core.http.impl.ServerConnection.processMessage(ServerConnection.java:313)
    at org.vertx.java.core.http.impl.ServerConnection.handleMessage(ServerConnection.java:94)
    at org.vertx.java.core.http.impl.DefaultHttpServer$ServerHandler.doMessageReceived(DefaultHttpServer.java:710)
    at org.vertx.java.core.http.impl.DefaultHttpServer$ServerHandler.doMessageReceived(DefaultHttpServer.java:600)
    at org.vertx.java.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:72)
    at org.vertx.java.core.net.impl.VertxHandler.channelRead(VertxHandler.java:155)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at org.vertx.java.core.http.impl.cgbystrom.FlashPolicyHandler.channelRead(FlashPolicyHandler.java:53)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at java.lang.Thread.run(Thread.java:745)

How to fix this?

Datagram test configure failure notices from Jenkins

Jenkins is showing failures for the datagram test_configure test, but I'm not able to reproduce the test failure, and I can't immediately see what the cause is. The failure is on an assertion related to a simple property change, so it seems odd that the behavior is inconsistent.

@normanmaurer have you seen the test output? Do you have any ideas as to why this would fail? I'm stumped, and hopefully it's not just because I didn't get enough sleep last night...

Jython fork exceptions

There's a problem in the jython fork, leading to :

*** Adding search_function: <function search_function at 0x2>
Traceback (most recent call last):
  File "worker.py", line 28, in <module>
  File "worker.py", line 11, in f__VertxInternalVert__8
    import StringIO
  File "/home/julien/Bureau/vert.x/dev/vertx_test/mods/io.vertx#lang-jython#1.0.0-SNAPSHOT/lib/jython-standalone-2.5.3-adapted.jar/Lib/difflib.py", line 35, in <module>
LookupError: no codec search functions registered: can't find encoding 'iso8859_1'
Exception in Python verticle 
Traceback (most recent call last):
  File "worker.py", line 28, in <module>
  File "worker.py", line 11, in f__VertxInternalVert__8
    import StringIO
  File "/home/julien/Bureau/vert.x/dev/vertx_test/mods/io.vertx#lang-jython#1.0.0-SNAPSHOT/lib/jython-standalone-2.5.3-adapted.jar/Lib/difflib.py", line 35, in <module>
LookupError: no codec search functions registered: can't find encoding 'iso8859_1'


Exception in Python verticle 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'f__VertxInternalVert__8_stop' is not defined

I managed to compile Jython yesterday with the fix found on http://bugs.jython.org/issue1746 (after testing with VisualVM, the permgen space issue is gone when importing calendar or encodings directly) but I'm not sure how I could test ThreadLocal memory leak issue (http://bugs.jython.org/issue1327)...

Well, any idea about these exceptions ?

Implement new EventBus send timeouts

The Java eventbus now supports sends with timeout, also the Message class supports replies with timeouts.

We should expose this new functionality in the Python API too

python asynchronous file system "last_access_time" error

Hello,

When I ran below python verticle, I got an error message.
As you can see from the result of "dir(props)", props Object has last_access_time. But it returned error.
Not only 'last_access_time', but also all other file related time attribute returns same error message.

I've installed vert.x version 2.0.2-final, jdk 1.7.0_51 and jython is vertx default module.
Any comment, I'll appreciate it.
thanks
=======================Source=====================
import vertx

fs = vertx.file_system()

def props_handler(err, props):
if not err:
print props
print dir(props)
print 'Size : %s' % ( props.size )
print 'regular : %s' % str(props.regular_file)
print props.last_access_time
"""
print 'Last accessed : %s' % str(props.last_access_time)
print 'Last modified : %s' % str(props.last_modified_time)
print 'directory : %s' % str(props.directory)
print 'regular : %s' % str(props.regular_file)
"""
else:
print err.getCause
print err.message
vertx.exit()

==========error message=============
Exception in Python verticle: null
Traceback (most recent call last):
File "pyclasspath/core/handlers.py", line 117, in handle
File "prop.py", line 11, in props_handler
"""
File "pyclasspath/core/file_system.py", line 41, in last_access_time
AttributeError: 'instancemethod' object has no attribute 'getTime'

Please ping me

Jordan please ping me if you see this.

I have tried your email address, but it doesn't seem you are monitoring it.

python cannot import classes relative to module directory

It seems that python's working directory is not the module's directory as it is described in the modules manual.

If I'm getting started with gradle:

git clone https://github.com/vert-x/vertx-gradle-template hello-module
cd hello-module/
./gradlew test
# ====> BUILD SUCCESSFUL

I have a module which I can populate with a trivial python main class:

cat > src/main/resources/hello.py <<EOF
import sys
print "hello! %r" % sys.path
EOF
sed -i 's/com.mycompany.myproject.PingVerticle/hello.py/' src/main/resources/mod.json
./gradlew runMod
# ====> hello! ['/tmp/hello-module/build/mods/io.vertx~lang-jython~2.0.0-beta3/lib/Lib', '/tmp/hello-module/build/mods/io.vertx~lang-jython~2.0.0-beta3/lib/jython-standalone-2.5.3-adapted.jar/Lib', '__classpath__', '__pyclasspath__/']

When I extend this main class to import another python class, which is located relative to my main class, then it will fail to load it:

echo 'import hello2' > src/main/resources/hello.py
echo 'print "this is hello2' > src/main/resources/hello2.py
./gradlew runMod
# ====> ImportError: No module named hello2

If I try to put that to-be-imported class into the relative directory __pyclasspath__/, which can be found in the output of the first hello.py above, then it won't be found either:

mkdir src/main/resources/__pyclasspath__
mv src/main/resources/hello2.py src/main/resources/__pyclasspath__/
./gradlew runMod
# ====> ImportError: No module named hello2

But if I move the __pyclasspath__ to my current working directory, then it works:

mv src/main/resources/__pyclasspath__ .
./gradlew runMod
# ====> this is hello2

Inconsistent naming in Buffer

The Buffer class's implementation of appendString and setString are named inconsistently with append_str and set_string. I think these should be named consistently with append_string and set_string or the alternative, but we can't break the API for now. Perhaps a proper method could be provided for consistency though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.