server/executionhandlers/ruby/connection.rb in cpee-2.1.50 vs server/executionhandlers/ruby/connection.rb in cpee-2.1.51

- old
+ new

@@ -18,10 +18,11 @@ require 'get_process_mem' class ConnectionWrapper < WEEL::ConnectionWrapperBase def self::loop_guard(arguments,id,count) # {{{ controller = arguments[0] + return false if controller.attributes['nednoamol'] tsn = Time.now tso = controller.loop_guard[id][:timestamp] rescue Time.now controller.loop_guard[id] = { :count => count, :timestamp => tsn } # if we have more than 100 loop iterations and the last one took less than 2 seconds, we slow the hell down tso + 2 > tsn && count > 100 @@ -140,10 +141,12 @@ @handler_passthrough = callback @controller.callback(self,callback,:'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position) status, result, headers = client.request type => params + @guard_files += result + if status == 561 @handler_endpoint = @handler_endpoint_orig params.delete_if { |p| p.name == 'original_endpoint' } params.each do |p| if p.name == 'attributes' @@ -279,11 +282,11 @@ else result = result[0] end end else - Riddl::Parameter::Array[*result] + result = Riddl::Parameter::Array[*result] end if result.is_a? String enc = detect_encoding(result) enc == 'OTHER' ? result : (result.encode('UTF-8',enc) rescue convert_to_base64(result)) else @@ -350,10 +353,11 @@ def callback(result=nil,options={}) recv = structurize_result(result) @controller.notify("activity/receiving", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => recv, :annotations => @anno) @guard_files += result + @handler_returnValue = simplify_result(result) @handler_returnOptions = options if options['CPEE_INSTANTIATION'] @controller.notify("task/instantiation", :'activity-uuid' => @handler_activity_uuid, :label => @label, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(options['CPEE_INSTANTIATION'])) end @@ -377,16 +381,18 @@ end end end def mem_guard() #{{{ - @guard_files.each do |p| + @guard_files.delete_if do |p| if p&.respond_to?(:close) p.close elsif p&.value&.respond_to?(:close) p.value.close end + true end + GC.start end #}}} def test_condition(mr,code,args) res = mr.instance_eval(code,'Condition',1) @controller.notify("gateway/decide", :instance_uuid => @controller.uuid, :code => code, :condition => (res ? "true" : "false"))