Hi Allan,
apologies for resurrecting this very old thread, but I'm kind of stuck again.
Ideally, I'd like to create the following commands:
b) set up a reusable socket connection object
c) evaluate expressions by sending them to the server using the connection object
I've set up environment variables in Textmate to hold my connection settings; also, I've created a variable called EXTEMPORE_CONNECTION which in theory should keep the pickled version of my server socket.
Here's my Python command:
>>>>>>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, socket
import pickle
xtm_host = str(os.environ.get('EXTEMPORE_HOST', "127.0.0.1"))
xtm_port = int(os.environ.get('EXTEMPORE_PORT', 7099))
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = xtm_host
PORT = xtm_port
sock.connect((HOST, PORT))
data = sock.recv(1024)
print(data) # welcome message, works.
os.environ['EXTEMPORE_CONNECTION'] = pickle.dumps(sock, -1) # *fails*
>>>>>>>
So I wonder if there's another way of approaching the problem; or, if by any chance, the same approach done via another language (eg Ruby) would not encounter any limitation..
Thanks in advance for the help,
Michele