-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New features for rate limiting (#19)
* Time and Size based rate limit, gzip compression and psutil for system properties * addressed review comment * resonseInterface to responseInterface * updated the testcases * added try-except for json.dumps and introduced constants for size limiting * Addressed comments regarding linting in code using Flake8
- Loading branch information
Showing
58 changed files
with
4,762 additions
and
4,592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import psutil | ||
|
||
|
||
def sanitize_for_serialization(obj): | ||
dict_obj = {} | ||
fields = obj._fields | ||
for i in fields: | ||
dict_obj[i] = str(obj.__getattribute__(i)) | ||
return dict_obj | ||
|
||
|
||
def get_system_info(): | ||
swap_memory = sanitize_for_serialization(psutil.swap_memory()) | ||
virtual_memory = sanitize_for_serialization(psutil.virtual_memory()) | ||
system = { | ||
"using.sdk": "true", | ||
'boot_time': str(psutil.boot_time()), | ||
'cpu_count': str(psutil.cpu_count()), | ||
'swap_memory_total': swap_memory["total"], | ||
'swap_memory_used': swap_memory["used"], | ||
'swap_memory_free': swap_memory["free"], | ||
'virtual_memory_total': virtual_memory["total"], | ||
'virtual_memory_available': virtual_memory["available"], | ||
'virtual_memory_used': virtual_memory["used"] | ||
} | ||
return system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.