ralhei / pyRserve

A python client for Rserve (network layer to remote R server)
Other
47 stars 13 forks source link

ConnectionResetError in rparser.py #22

Closed Haobo1108 closed 4 years ago

Haobo1108 commented 4 years ago

Dear Sir, I found the package works well on not heavy calculation. However, in my case, I pass a list of tensor to perform the tensor calculation. It reported an error (An existing connection was forcibly closed by the remote host) when running rparser.py.

The tensor is sparse. I am not sure what work rparser.py is doing. I am looking forward to your reply.

Sincerely

ralhei commented 4 years ago

What usually helps best to track down problems is to provide minimal code samples that reproduce the problem. Without even getting a traceback from your side I cannot do anything.

Haobo1108 commented 4 years ago

Sorry for not providing helpful information. My code can be summarized as below

from rserv_connection_pool import *

urls=['127.0.0.1:6311']

max_number_of_thread = len(urls)
pool_R = RConnectionPool(urls) 
for i in range(len(urls)):
    conn = pool_R.make_connection()
    pool_R._in_use_connections.add(conn)
    print(conn.get_id())
    conn.eval('source("Complex.R",encoding="utf-8")')
    #conn.eval('source("Easy.R",encoding="utf-8")')

for conn in list(pool_R._in_use_connections):
    conn.close()

def f(x,z):
    conn = pool_R.get_connection()
    #print(conn.get_id())
    f_value = conn.conn.r.forecast(x,z)
    conn.close()
    return f_value

The ''rserv_connection_pool" file is mainly to manage the connections. "Easy.R" is a Rscript which only has one simple function, like a+b. "Complex.R" is more complex and does tensor calculation. When I debug with Easy.R, it works. However, it reports the following bug with Complex.R.

(<class 'ConnectionResetError'>, ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None), <traceback object at 0x000002A91365AA48>)

And it happens at the line 227, rparser.py.

fragment = self._read(bytesToRead)