vert-x / mod-lang-jython Goto Github PK
View Code? Open in Web Editor NEWVert.x 2.x is deprecated - use instead
Home Page: http://vertx.io
License: Other
Vert.x 2.x is deprecated - use instead
Home Page: http://vertx.io
License: Other
Event bus send timeouts have been added to Vert.x core. Timeouts should be implemented in the Python module as well.
... on HttpClient and HttpServer by exposing the getter/setter for MaxWebSocketFrameSize
Thanks!
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
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 :-)
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?
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...
... and also expose uri() method in ServerWebSocket
After applying fix 525 from vertx core (https://github.com/vert-x/vert.x/pull/525) and #1, I'm still getting leaks coming from encodings/init.py (http://bugs.jython.org/issue1746).
The standalone jar in lib folder after building the module seems to be the same than the one available on jython.org (MD5 test), causing those leaks.
Do you have hosted your jython fork somewhere on bitbucket ?
Thank you.
Thanks!
Thanks!
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 ?
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
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'
Jordan please ping me if you see this.
I have tried your email address, but it doesn't seem you are monitoring it.
This should be changed as it is a Ruby thing not a Python thing
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
This page: http://vertx.io/api/pydoc/core.html (200)
links out to missing files for submodules, e.g.
See also:
eclipse-vertx/vert.x@633ccaa
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.
Thanks!
The Vert.x testframework is deprecated. I think the Python test suite should be migrated to the new testtools testing framework.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.