-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make analysis of session a separate background task #395
Conversation
don't forget to cancel the task in |
b40d09b
to
024de0b
Compare
tanner/sessions/session_analyzer.py
Outdated
session = json.loads(session) | ||
result = await self.create_stats(session, redis_client) | ||
await self.queue.put(result) | ||
await self.save_session(redis_client, pg_client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need a separate save function or we can do everything in current function?
anyway, save should not be called after you put each session into the queue, it should be called once
tanner/sessions/session_manager.py
Outdated
@@ -95,7 +95,7 @@ async def delete_session(self, sess, redis_client, pg_client): | |||
await sess.remove_associated_env() | |||
try: | |||
await redis_client.set(sess.get_uuid(), sess.to_json()) | |||
await self.analyzer.analyze(sess.get_uuid(), redis_client, pg_client) | |||
# await self.analyzer.analyze(sess.get_uuid(), redis_client, pg_client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented line
tanner/sessions/session_analyzer.py
Outdated
session = json.loads(session) | ||
result = await self.create_stats(session, redis_client) | ||
await self.queue.put(result) | ||
await self.save_session(redis_client, pg_client) | ||
|
||
async def save_session(self, redis_client, pg_client): | ||
while not self.queue.empty(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have try for redis error, but not postgres errors
c2c8a23
to
55da9d5
Compare
tanner/sessions/session_analyzer.py
Outdated
) | ||
except aioredis.ProtocolError as redis_error: | ||
self.logger.exception( | ||
"Error with redis. Session will be returned to the queue: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no queue anymore to return the session to
) | ||
# This is the key which stores all the dorks. | ||
# It matches the pattern of other keys. | ||
except aioredis.errors.ReplyError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid this by using another pattern for sessions?
Also drop the usage of queue during analyze function
55da9d5
to
ccdd8d6
Compare
@mzfr could you please fix the tests? |
@afeena Yes I am working on them, Trying to understnad why they are failing. |
Pull Request Test Coverage Report for Build 1381
💛 - Coveralls |
This PR will separate the analysis and deletion of the session.