Python IPC server for high-performance communication with Node.js applications using TCP sockets
Project description
IPC Framework - Inter-Process Communication
Efficient Inter-Process Communication Framework for Python โ Node.js backend integration. This is the Python server package that enables seamless bidirectional communication with Node.js applications using TCP sockets.
๐ Python Server Package
This package provides the Python IPC server for communication with Node.js clients.
โ Production Ready Features:
- โ TCP socket server (high-performance, low-latency)
- โ Hierarchical application and channel management
- โ Request/response and publish/subscribe patterns
- โ Connection pooling and auto-reconnection support
- โ Thread-safe operation with robust error handling
๐ Quick Start
Installation
# Install Python IPC server
pip install ipc-framework
# Install Node.js client (separate package)
npm install @ifesol/ipc-framework-nodejs
Python Server Usage
from ipc_framework import FrameworkServer, MessageType
import time
# Create server
server = FrameworkServer(host="localhost", port=8888)
# Create application and channel
app = server.create_application("my_app", "My Application")
api_channel = app.create_channel("api")
# Handle requests from Node.js clients
def handle_request(message):
action = message.payload.get('action')
if action == 'get_data':
response = message.create_response({
'success': True,
'data': {'timestamp': time.time(), 'message': 'Hello from Python!'},
'server': 'Python IPC Framework'
})
connection = server.connection_manager.get_connection(
message.payload.get('connection_id')
)
server.send_to_connection(connection, response)
api_channel.set_handler(MessageType.REQUEST, handle_request)
print("๐ Python IPC Server starting on localhost:8888")
server.start()
Node.js Client Usage
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
async function main() {
const client = new IPCClient('my_app', {
host: 'localhost',
port: 8888
});
try {
await client.connect();
console.log('โ
Connected to Python server!');
const response = await client.sendRequest('api', {
action: 'get_data'
});
console.log('๐จ Response from Python:', response.payload);
} catch (error) {
console.error('โ Error:', error.message);
} finally {
client.disconnect();
}
}
main();
๐ฏ Architecture Features
โ Production-Ready Server:
- High-performance TCP sockets for low-latency communication
- Hierarchical structure with applications and channels
- Message routing and automatic connection management
- Thread-safe operations with robust error handling
โ Communication Patterns:
- Request/Response - Direct client-server communication
- Publish/Subscribe - Real-time notifications and broadcasts
- Channel-based routing - Organized message handling
- Connection pooling - Efficient resource management
๐๏ธ Integration with Node.js
This Python server works seamlessly with Node.js applications. Here's how to connect an Express.js app:
Node.js Express.js Integration:
const express = require('express');
const { IPCClient } = require('@ifesol/ipc-framework-nodejs');
const app = express();
const pythonClient = new IPCClient('web_api');
app.use(express.json());
// Initialize connection to Python IPC server
pythonClient.connect().then(() => {
console.log('๐ Connected to Python IPC server');
});
// API endpoint proxying to Python backend
app.post('/api/process', async (req, res) => {
try {
const result = await pythonClient.sendRequest('processing', {
action: 'process_user_data',
data: req.body,
connection_id: pythonClient.connectionId
});
res.json(result.payload);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000, () => {
console.log('๐ Express server running on port 3000');
console.log('๐ก Proxying requests to Python IPC server');
});
๐ Performance Characteristics
| Feature | Performance | Details |
|---|---|---|
| Connection Handling | Sub-millisecond | Fast TCP connection establishment |
| Message Processing | <1ms latency | Direct socket communication |
| Concurrent Connections | 100+ clients | Thread-safe connection management |
| Message Throughput | High-volume | Efficient message routing |
| Memory Usage | Low footprint | Optimized Python implementation |
| Error Recovery | Automatic | Robust connection cleanup |
๐ฏ Use Cases
This Python IPC server enables powerful hybrid architectures:
Backend Services
- AI/ML model serving - Host machine learning models and serve predictions to Node.js frontends
- Data processing pipelines - Heavy computational tasks handled by Python, coordinated with Node.js
- Real-time analytics - Python analytics engines feeding real-time dashboards
- Scientific computing - NumPy/SciPy computations accessible from Node.js applications
Microservice Architecture
- Polyglot microservices - Python services integrated with Node.js API gateways
- Event-driven architecture - Python services publishing events to Node.js consumers
- Service mesh integration - Python backend services in cloud-native environments
- Legacy system integration - Bridge existing Python systems with modern Node.js frontends
Hybrid Applications
- E-commerce platforms - Python inventory/pricing engines with Node.js storefronts
- Financial services - Python quantitative analysis with Node.js trading interfaces
- IoT platforms - Python device controllers with Node.js monitoring dashboards
- Chat applications - Python NLP processing with Node.js real-time messaging
๐ Why Choose IPC over HTTP?
| HTTP API Approach | IPC Framework |
|---|---|
| โ High latency overhead | โ Direct TCP communication |
| โ Request/response only | โ Request/response + pub/sub |
| โ Manual connection management | โ Automatic reconnection |
| โ Complex error handling | โ Built-in fault tolerance |
| โ No real-time capabilities | โ Live notifications |
| โ Stateless limitations | โ Persistent connections |
๐ Companion Packages
This Python server works with the Node.js client package:
- Node.js Client: @ifesol/ipc-framework-nodejs - Production-ready TCP client
- Installation:
npm install @ifesol/ipc-framework-nodejs - Documentation: Node.js Package Docs
๐ Getting Started
-
Install the Python server:
pip install ipc-framework
-
Install the Node.js client:
npm install @ifesol/ipc-framework-nodejs
-
Run the examples above to see the integration in action!
๐ Documentation
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Contributions welcome! Help us improve the Python โ Node.js IPC communication experience.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipc_framework-1.1.2.tar.gz.
File metadata
- Download URL: ipc_framework-1.1.2.tar.gz
- Upload date:
- Size: 81.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf777063eac1373ea1f83e2b636009e66cf68b4daf94f6b1c81ea67e7decbe9b
|
|
| MD5 |
39ec7c886e0fd447f928c00c6e73b98d
|
|
| BLAKE2b-256 |
a4fd477ccadec725ffc64d1f8bbe4ec615e6242624ae9d82cf089f9bce3027a4
|
File details
Details for the file ipc_framework-1.1.2-py3-none-any.whl.
File metadata
- Download URL: ipc_framework-1.1.2-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87c42cbd4c4da9f3c00ebe8a91ac66322064f87f748ce60ed97ac53793d013e0
|
|
| MD5 |
f9297d970cceec77aa0102ddbbe519e5
|
|
| BLAKE2b-256 |
3851677270f787e897b42fa8ad0597d5f1864d495d9f73b6db5e778f6798a62b
|