Skip to content

Instantly share code, notes, and snippets.

View bartdag's full-sized avatar
💭
🏓 🐨 💡

Barthelemy Dagenais bartdag

💭
🏓 🐨 💡
View GitHub Profile
@bartdag
bartdag / ExampleListener.java
Created March 12, 2016 01:58
Py4J Listener Callback Example
package py4j.examples;
public interface ExampleListener {
Object notify(Object source);
}
from contextlib import contextmanager
import logging
logger = logging.getLogger("root")
class History(object):
def __init__(self, value):
self.value = value
@bartdag
bartdag / README.md
Created October 22, 2017 01:06
Py4J - Multiple GatewayServer and CallbackServer instances

Py4J Multiple GatewayServer and CallbackServer instances

Compile and run TestApplication.java with py4j.jar in your classpath.

Then execute python3 test.py

Explanations

This creates three pairs of GatewayServer and CallbackServer with different ports on both the Java and Python sides. Python is driving the communication by asking Java to print