Search test library by skills or roles
โŒ˜ K

Adaface Sample Flask Questions

Here are some sample Flask questions from our premium questions library (10273 non-googleable questions).

Skills

๐Ÿง Question

Medium

Application Context and Request Dispatching
Application Context
Request Lifecycle
Thread-Safety
Solve
Consider a complex Flask application that uses an application factory pattern for scalability and flexibility. The application also utilizes global variables to manage configurations across different parts of the app. Review the following pseudo-code, which illustrates a portion of this application where an issue with application context might arise when deploying:
 image
In this scenario, where the application is configured to run with multiple threads, what is the potential issue that could arise when processing multiple requests concurrently?
A: The db_connection in g might be shared across requests leading to data integrity issues.
            B: The USE_CACHE configuration might reset to its default value in between requests.
            C: Multiple threads might cause the application to crash due to improper locking mechanisms.
            D: There will be no issues as Flask naturally handles application contexts per request in a thread-safe manner.
            E: The configuration change in current_app.config['USE_CACHE'] will not be visible to the request handlers.

Medium

Multithreading
Application Factory
Thread-Safety
Context Management
Solve
Examine the advanced Flask application setup below which uses an application factory pattern and is intended to handle multiple user requests simultaneously using threading. The developer has configured an endpoint to perform data processing based on user inputs and global settings. However, the application might exhibit unexpected behavior due to its handling of the Flask context and multithreading. Your task is to determine the output of this setup under concurrent requests.
            
            The pseudo-code for the Flask application is as follows:
 image
In this code, the threads are launched almost simultaneously. Thread1 executes a POST request to /set_cache, and Thread2 executes a GET request to /get_data. What is the likely output of Thread2 when it runs concurrently with Thread1?
A: "Using Cache"
            B: "Not Using Cache"
            C: The output is non-deterministic, depending on the execution timing of Thread1 and Thread2.
            D: A Flask RuntimeError due to the application context being improperly managed.
            E: No response due to a deadlock in resource access between the threads.
๐Ÿง Question๐Ÿ”ง Skill

Medium

Application Context and Request Dispatching
Application Context
Request Lifecycle
Thread-Safety

2 mins

Flask
Solve

Medium

Multithreading
Application Factory
Thread-Safety
Context Management

2 mins

Flask
Solve
๐Ÿง Question๐Ÿ”ง Skill๐Ÿ’ช DifficultyโŒ› Time
Application Context and Request Dispatching
Application Context
Request Lifecycle
Thread-Safety
Flask
Medium2 mins
Solve
Multithreading
Application Factory
Thread-Safety
Context Management
Flask
Medium2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1500+ companies in 80+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
โ— Online
Previous
Score: NA
Next
โœ–๏ธ