Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Python RFC Server problem

Help
2005-05-04
2013-04-11
  • 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 ?
        srv.main_loop(sys.argv)
      File "C:\Python23\lib\site-packages\pysap.py", line 2158, in main_loop
        func_rc=func_obj.f(handle)
      File "C:\Python23\lib\site-packages\pysap.py", line 1562, in rf
        self._get_data(handle)
      File "C:\Python23\lib\site-packages\pysap.py", line 1537, in _get_data
        self.stack=self.args.get_stack_srv()
      File "C:\Python23\lib\site-packages\pysap.py", line 1306, in get_stack_srv
        self.__stack=RfcAllocParamSpace(self.__num_params('E'),self.__num_params('I'
    ),self.__num_params('T'))
    WindowsError: exception: access violation reading 0xFFFFFFFD

    My function is defined as:

    class ViewScanFunc(pysap.RFC_SERV_FUNC):
      _name_='Z_SA_VIEW_SCAN'
      _importing_=[('FOLDER','C',3), ('FILENAME','C',128)]
      _exporting_=[('RET_CODE','I')]
     
      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?

    Thanks.

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

      pysap.SapRfcError: "102 - RFC_ERROR_COMMUNICATION, CPIC-CALL: 'CMSEND'\n\nERROR
            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.