Skip to content

Commit 1547d17

Browse files
Yale Wangmeta-codesync[bot]
authored andcommitted
Add cython API to RequestContext/ConnContext to get cpp object
Summary: Added getter helpers to obtain underlying C++ objects from RequestContext/ConnContext Python Objects. Reviewed By: yfeldblum, ahilger, prakashgayasen Differential Revision: D83774208 fbshipit-source-id: a6df671663436b423805064d50ca39ad5c75c5ae
1 parent aee8978 commit 1547d17

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

third-party/thrift/src/thrift/lib/python/server/request_context.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,7 @@ cdef class WriteHeaders(Headers):
138138
cdef _fbthrift_create(RequestContext ctx)
139139

140140
cdef object THRIFT_REQUEST_CONTEXT
141+
142+
cdef api Cpp2RequestContext* extract_cpp_request_context(object ctx) except NULL
143+
144+
cdef api Cpp2ConnContext* extract_cpp_connection_context(object ctx) except NULL

third-party/thrift/src/thrift/lib/python/server/request_context.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,9 @@ cdef inline _get_SocketAddress(const cfollySocketAddress* sadr):
234234
os.fsdecode(sadr.getPath())
235235
)
236236
)
237+
238+
cdef api Cpp2RequestContext* extract_cpp_request_context(object ctx) except NULL:
239+
return (<RequestContext?>ctx)._ctx
240+
241+
cdef api Cpp2ConnContext* extract_cpp_connection_context(object ctx) except NULL:
242+
return (<ConnectionContext?>ctx)._ctx

0 commit comments

Comments
 (0)