Skip to content

Commit

Permalink
Add more debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Dec 3, 2023
1 parent fa44079 commit f9df140
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions integration_tests/subroutes/di_subrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


@di_subrouter.get("/subrouter_router_di")
def sync_subrouter_route_dependency(request, router_dependencies):
def sync_subrouter_route_dependency(router_dependencies):
return router_dependencies["ROUTER_DEPENDENCY"]

@di_subrouter.get("/subrouter_global_di")
def sync_subrouter_global_dependency(request, global_dependencies):
def sync_subrouter_global_dependency(global_dependencies):
return global_dependencies["GLOBAL_DEPENDENCY"]
6 changes: 3 additions & 3 deletions robyn/dependency_injection.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
""" This is Robyn's dependency injection file.
"""
from typing import Any

class DependencyMap:
def __init__(self):
#'request' and 'response' mappings are needed for when constructing deps_to_pass in router.py
self.global_dependency_map = {}
self.global_dependency_map: dict[str, Any] = {}
# {'router': {'dependency_name': dependency_class}
self.router_dependency_map = {}
self.router_dependency_map: dict[str, dict[str, Any]] = {}

def add_router_dependency(self, router, **kwargs):
"""Adds a dependency to a route.
Expand Down
10 changes: 2 additions & 8 deletions robyn/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@ def add_route(
exception_handler: Optional[Callable],
injected_dependencies: dict,
) -> Union[Callable, CoroutineType]:
# this should not be an unordered map. should be a list only
@wraps(handler)
async def async_inner_handler(*args, **kwargs):
print("This is the args", args)
print("This is the kwargs", kwargs)
try:
response = self._format_response(
await handler(*args, **kwargs),
Expand All @@ -117,7 +114,6 @@ async def async_inner_handler(*args, **kwargs):
@wraps(handler)
def inner_handler(*args, **kwargs):
try:
# do we even need this?
response = self._format_response(
handler(*args, **kwargs),
)
Expand All @@ -140,7 +136,7 @@ def inner_handler(*args, **kwargs):
if dependency in params:
new_injected_dependencies[dependency] = injected_dependencies[dependency]
else:
_logger.warning(f"Dependency {dependency} is not used in the handler {handler.__name__}")
_logger.debug(f"Dependency {dependency} is not used in the handler {handler.__name__}")


if iscoroutinefunction(handler):
Expand Down Expand Up @@ -179,9 +175,7 @@ def add_route(self, middleware_type: MiddlewareType, endpoint: str, handler: Cal
if dependency in params:
new_injected_dependencies[dependency] = injected_dependencies[dependency]
else:
logging.warning(f"Dependency {dependency} is not used in the middleware handler {handler.__name__}")

print("This is new injected dependencies", new_injected_dependencies)
_logger.debug(f"Dependency {dependency} is not used in the middleware handler {handler.__name__}")



Expand Down
2 changes: 1 addition & 1 deletion robyn/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def inner(handler):
if dependency in params:
new_injected_dependencies[dependency] = injected_dependencies[dependency]
else:
_logger.warning(f"Dependency {dependency} is not used in the handler {handler.__name__}")
_logger.debug(f"Dependency {dependency} is not used in the handler {handler.__name__}")

self.methods[type] = FunctionInfo(handler, is_async, num_params, params, kwargs=new_injected_dependencies)
self.robyn_object.add_web_socket(self.endpoint, self)
Expand Down

0 comments on commit f9df140

Please sign in to comment.