Vaadin abnormal memory consumption (memoryLeak?)

for a project I’m working on (Spring Boot 2.7.9 + Vaadin 14.9.7) I’m experiencing a strange heap memory usage. Attached to this post you can find the first objects by top memory usage in my application. I see there is a big usage from PendingJavaScriptInvocation and UIInternals$JavaScriptInvocation. The application is accessed by 500 users but… Read More Vaadin abnormal memory consumption (memoryLeak?)

Succinctly wrap a list in a callable that returns each list element in order for each successive call

I feel like I must be missing something obvious, but I can’t seem to find a succinct way of creating a a callable that returns elements of a list in order for each call. E.g. In [1]: class CallableList: …: def __init__(self, list_): …: self.list = list_ …: self.pos = -1 …: def __call__(self): …:… Read More Succinctly wrap a list in a callable that returns each list element in order for each successive call

How to inspect return type of Callable

Let’s say I have something like the following: import inspect from collections.abc import Callable # Using Python 3.10+ from typing import get_type_hints def foo(arg: Callable[…, int]) -> None: pass type_hints = get_type_hints(foo)["arg"] annotation = inspect.signature(foo).parameters["arg"].annotation # How can one get the return type `int` from either of these? I can figure out how to get… Read More How to inspect return type of Callable

Why do I keep getting the error "File "TypeError: 'int' object is not callable"?

Hope someone can help explain why I keep getting the following error in Python. Python version: Python 3.10.4 OS: Windows 11 in a vm Steps to reproduce the error in REPL or JuyterLab. def minmax(items): return min(items), max(items) lst = [98, 34, 78, 1, 0, -10, -19, -1] (min, max) = minmax(lst) # **no error**… Read More Why do I keep getting the error "File "TypeError: 'int' object is not callable"?

How can i test the promise function at jest with react testing library?

I have this function and i am trying to test it here: I am trying to make the onClose function callable, but I get an error at this line => expect(onClose).toHaveBeenCalled(); >Solution : Since your onClose function is not called directly but asyncronously, after some other action you should use the react testing library async… Read More How can i test the promise function at jest with react testing library?

Laravel 9 with argument 2 must be of type ?callable, string given

I’m following a tutorial. In the controller I’m using with to send a success message. public function store(Request $request) { $request->validate([ ‘recipe’ => ‘required’, ‘rating’ => ‘required’, ]); Recipe::create($request->all()); return redirect()->route(‘recipes.index’) -with(‘success’, ‘Recipe created successfully’); } I’m getting an error message once the form is submitted and I’m redirected to the index page the code… Read More Laravel 9 with argument 2 must be of type ?callable, string given

How to get in a superclass full names of all methods in subclasses that start with the same two letters in python

I have number of subclasses all of which have number of methods whose names start with "on.." eg.: def on_index(self): raise NotImplementedError() def on_spiking_intent(self): raise NotImplementedError() def on_no_option(self): raise NotImplementedError() I would like to write a method in the superclass which prints a list of all the "on…" methods of its subclasses and specifies to… Read More How to get in a superclass full names of all methods in subclasses that start with the same two letters in python

I know eval() is bad practice; is there an alternative for my code which involves getting the __doc__ of all funcs in all files in a folder?

I’m making a project which involves importing a directory as a module (it has an __init__.py) then iterating through all files in that directory and printing the docstring of all the functions in each file. This is my main.py code, in which I have to use eval() to convert the file name from a string… Read More I know eval() is bad practice; is there an alternative for my code which involves getting the __doc__ of all funcs in all files in a folder?