Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Python RFC Server problem

  • Hello,

    I implemented a RFC Server using your documentation in sourceforge all was OK except than when I call more than 5-7 times (it depends) my python function module from SAP I get next error:

    [Thr 2040] RFC         functionname  = Z_SA_VIEW_SCAN
    [Thr 2040] RFC <* RfcGetNameEx [2] : returns 0:RFC_OK
    Traceback (most recent call last):
      File "sap_sa.py", line 44, in ?
      File "C:\Python23\lib\site-packages\pysap.py", line 2158, in main_loop
      File "C:\Python23\lib\site-packages\pysap.py", line 1562, in rf
      File "C:\Python23\lib\site-packages\pysap.py", line 1537, in _get_data
      File "C:\Python23\lib\site-packages\pysap.py", line 1306, in get_stack_srv
    WindowsError: exception: access violation reading 0xFFFFFFFD

    My function is defined as:

    class ViewScanFunc(pysap.RFC_SERV_FUNC):
      _importing_=[('FOLDER','C',3), ('FILENAME','C',128)]
      def run(self,handle):
        r = s.view_scan(self['FOLDER'], self['FILENAME'])
        self['RET_CODE'] = 0

    I am using pysaprfc 1.0 and ctypes 0.0.6, Have you had any experiences about this error?


    • I've similar problems with multiple calls to RFC's with threads, with the first there is no problem, but at the second...

            program state check for conversation 56818796\n\nTIME        Mon Aug 21 10
      :31:34 2006\nRELEASE     640\nCOMPONENT   CPIC (TCP/IP)\nVERSION     3\nRC
          471\nMODULE      r3cpic.c\nLINE        2576\nDETAIL      called function STS
      END in state state=BUFFER_DATA2\nCOUNTER     1"
      Unhandled exception in thread started by <bound method xxxx.get_master_data

      WindowsError: exception: access violation writing 0x01624000

    • Based on my experience (I did a multithreaded application using pysap some time ago) calling RFC using the same connection is *not* thread-safe. I don't know what's the culprit: mine implementation or design limits of RFC library. The problem is the RFCs are done asynchronously and if you do another RFC from second thread while the RFC from the first thread still waits for the result the inner state of connection get mixed up. There are two possible solutions: either use separate RfcConnection object per thread or use locks.