Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Justin
slapos.toolbox
Commits
8d801fe6
Commit
8d801fe6
authored
Nov 02, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue multiple callbacks
parent
24a50d1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
+18
-13
slapos/pubsub/__init__.py
slapos/pubsub/__init__.py
+18
-13
No files found.
slapos/pubsub/__init__.py
View file @
8d801fe6
from
datetime
import
datetime
from
datetime
import
datetime
import
csv
import
csv
import
feedparser
import
feedparser
import
io
import
socket
import
socket
import
json
import
json
import
time
import
time
...
@@ -82,24 +83,28 @@ def notify():
...
@@ -82,24 +83,28 @@ def notify():
except
AttributeError
:
except
AttributeError
:
abort
(
httplib
.
BAD_REQUEST
)
abort
(
httplib
.
BAD_REQUEST
)
with
open
(
callback_filepath
,
'r'
)
as
callback_file
:
callback
=
callback_file
.
read
()
abort_it
=
False
timestamp
=
int
(
math
.
floor
(
time
.
mktime
(
feed
.
feed
.
updated_parsed
)))
for
callback
in
io
.
open
(
callback_filepath
,
'r'
,
encoding
=
'utf8'
):
timestamp
=
int
(
math
.
floor
(
time
.
mktime
(
feed
.
feed
.
updated_parsed
)))
equeue_request
=
json
.
dumps
(
dict
(
equeue_request
=
json
.
dumps
({
command
=
callback
,
'command'
:
callback
,
timestamp
=
timestamp
,
'timestamp'
:
timestamp
,
)
)
}
)
equeue_socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
equeue_socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
equeue_socket
.
connect
(
app
.
config
[
'EQUEUE_SOCKET'
])
equeue_socket
.
connect
(
app
.
config
[
'EQUEUE_SOCKET'
])
equeue_socket
.
send
(
equeue_request
)
equeue_socket
.
send
(
equeue_request
)
result
=
equeue_socket
.
recv
(
len
(
callback
))
result
=
equeue_socket
.
recv
(
len
(
callback
))
equeue_socket
.
close
()
equeue_socket
.
close
()
if
result
!=
callback
:
if
result
!=
callback
:
abort_it
=
True
if
abort_it
:
# XXX if possible, communicate info about the failed callbacks
abort
(
httplib
.
INTERNAL_SERVER_ERROR
)
abort
(
httplib
.
INTERNAL_SERVER_ERROR
)
return
''
,
httplib
.
NO_CONTENT
return
''
,
httplib
.
NO_CONTENT
...
...
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