Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
19ef7a29
Commit
19ef7a29
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
python: add some doc
parent
6850e012
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/opendht.pyx
+13
-0
13 additions, 0 deletions
python/opendht.pyx
with
13 additions
and
0 deletions
python/opendht.pyx
+
13
−
0
View file @
19ef7a29
...
...
@@ -269,7 +269,14 @@ cdef class DhtRunner(_WithID):
return
self
.
thisptr
.
getRoutingTablesLog
(
af
).
decode
()
def
getSearchesLog
(
self
,
cpp
.
sa_family_t
af
):
return
self
.
thisptr
.
getSearchesLog
(
af
).
decode
()
def
get
(
self
,
InfoHash
key
,
get_cb
=
None
,
done_cb
=
None
):
"""
Retreive values associated with a key on the DHT.
key -- the key for which to search
get_cb -- is set, makes the operation non-blocking. Called when a value is found on the DHT.
done_cb -- optional callback used when get_cb is set. Called when the operation is completed.
"""
if
get_cb
:
cb_obj
=
{
'
get
'
:
get_cb
,
'
done
'
:
done_cb
}
ref
.
Py_INCREF
(
cb_obj
)
...
...
@@ -294,6 +301,12 @@ cdef class DhtRunner(_WithID):
lock
.
wait
()
return
res
def
put
(
self
,
InfoHash
key
,
Value
val
,
done_cb
=
None
):
"""
Publish a new value on the DHT at key.
key -- the DHT key where to put the value
val -- the value to put on the DHT
done_cb -- optional callback called when the operation is completed.
"""
cb_obj
=
{
'
done
'
:
done_cb
}
ref
.
Py_INCREF
(
cb_obj
)
self
.
thisptr
.
put
(
key
.
_infohash
,
val
.
_value
,
cpp
.
Dht
.
bindDoneCb
(
done_callback
,
<
void
*>
cb_obj
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment