60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""Lock leak probe helpers (no cloud, A4H only): the enqueue reader class and a controlled kill of a writing client."""
|
|
import json, os, signal, subprocess, sys, time
|
|
sys.path.insert(0, "/Users/erhankeseli/projects/abap-llm/harness")
|
|
from harness.adt_client import load_env
|
|
load_env("/Users/erhankeseli/projects/abap-llm/harness/.env")
|
|
from harness.mcp_client import McpClient
|
|
from harness.runner import delete_uris
|
|
|
|
READER = "ZPROBE0EQ_LOCKS"
|
|
READER_SRC = """CLASS zprobe0eq_locks DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
PUBLIC SECTION.
|
|
INTERFACES if_oo_adt_classrun.
|
|
ENDCLASS.
|
|
CLASS zprobe0eq_locks IMPLEMENTATION.
|
|
METHOD if_oo_adt_classrun~main.
|
|
DATA lt_enq TYPE STANDARD TABLE OF seqg3 WITH DEFAULT KEY.
|
|
DATA lv_subrc TYPE sy-subrc.
|
|
CALL FUNCTION 'ENQUEUE_READ'
|
|
EXPORTING gclient = sy-mandt gname = '' garg = '' guname = ''
|
|
IMPORTING subrc = lv_subrc
|
|
TABLES enq = lt_enq
|
|
EXCEPTIONS communication_failure = 1 system_failure = 2 OTHERS = 3.
|
|
DATA(lv_n) = 0.
|
|
LOOP AT lt_enq ASSIGNING FIELD-SYMBOL(<l>).
|
|
lv_n = lv_n + 1.
|
|
DATA(lv_line) = ||.
|
|
DO.
|
|
ASSIGN COMPONENT sy-index OF STRUCTURE <l> TO FIELD-SYMBOL(<f>).
|
|
IF sy-subrc <> 0. EXIT. ENDIF.
|
|
DATA(lo_d) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_data( <l> ) ).
|
|
DATA(lv_name) = lo_d->components[ sy-index ]-name.
|
|
IF <f> IS NOT INITIAL.
|
|
lv_line = lv_line && lv_name && '=' && condense( |{ <f> }| ) && ' '.
|
|
ENDIF.
|
|
ENDDO.
|
|
out->write( lv_line ).
|
|
ENDLOOP.
|
|
out->write( |enqueue entries listed: { lv_n } of { lines( lt_enq ) } (subrc { lv_subrc })| ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|
|
"""
|
|
|
|
def ensure_reader(m, force=False):
|
|
e, t = m.call("sap_search_object", {"query": READER})
|
|
if READER not in t or force:
|
|
if READER not in t:
|
|
m.call("sap_create_object", {"objectType": "CLAS", "objectName": READER, "packageName": "$TMP", "description": "enqueue reader probe"})
|
|
e, t = m.call("sap_push_source", {"objectType": "CLAS", "objectName": READER, "source": READER_SRC})
|
|
if '"success":true' not in t.replace(" ", ""):
|
|
print("reader activation:", t[:600])
|
|
|
|
def read_locks(m):
|
|
e, t = m.call("sap_run_class", {"className": READER})
|
|
return t
|
|
|
|
if __name__ == "__main__":
|
|
with McpClient() as m:
|
|
ensure_reader(m, force=True)
|
|
print(read_locks(m)[:3500])
|