Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
crawler
Commits
1e204039
Commit
1e204039
authored
Jan 07, 2021
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8d30e4c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
rpc_data_to_answer.py
crawler_sys/utils/rpc_data_to_answer.py
+38
-3
No files found.
crawler_sys/utils/rpc_data_to_answer.py
View file @
1e204039
...
...
@@ -6,7 +6,38 @@
import
requests
import
typing
from
crawler.crawler_sys.utils.rpc
import
rpc_invoker
,
get_rpc_invoker
import
asyncio
from
gm_client.rpc
import
create_default_invoker
from
gm_client.rpc.internal.context
import
ClientContext
async
def
main
():
ctx
=
ClientContext
(
timeout
=
3
,
metadata
=
{})
ctx
.
session_key
=
"xxxxxx"
ctx
.
device_id
=
"device-123456789"
ctx
.
user_id
=
123456
invoker
=
create_default_invoker
(
debug
=
True
)
.
with_config
(
dump_curl
=
True
)
res
=
await
invoker
[
"diagnosis/test"
](
ctx
,
echo
=
"hello"
)
print
(
res
.
success
)
print
(
res
.
unwrap
())
print
(
res
)
# metadata = Metadata(
# session_key=
# )
# GM-Meta-xxxxxxx
results
=
await
asyncio
.
gather
(
*
(
invoker
[
"diagnosis/test"
](
ctx
,
echo
=
str
(
i
))
for
i
in
range
(
3
)
))
print
(
results
)
"""
https://www.yuque.com/docs/share/f4abe44b-6593-46b4-b280-5c87e4db2c85?#
rpc: cims/question/batch_create 创建问题
...
...
@@ -43,8 +74,12 @@ def post_data(data_dict:typing.Dict,rpc_type:str) -> typing.Dict:
data
=
{
'requests'
:
'[{"params": {"replies": [{
%
s}]}, "method": "
%
s, "timeout": 120}]'
%
(
str
(
data_dict
),
rpc_type
)
}
rpc_client
=
get_rpc_invoker
()
res
=
rpc_client
[
rpc_type
]()
.
unwrap
()
invoker
=
create_default_invoker
(
debug
=
True
)
.
with_config
(
dump_curl
=
True
)
res
=
await
invoker
[
rpc_type
](
**
data_dict
)
print
(
res
.
success
)
print
(
res
.
unwrap
())
print
(
res
)
return
res
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment