The send_async_email function lacks app.app_context(), so it may fail or behave unexpectedly.
Final Answer:
Missing Flask app context in thread -> Option A
Quick Check:
Threads need app context to access Flask safely [OK]
Hint: Always use app.app_context() inside threads [OK]
Common Mistakes:
Ignoring app context in threads
Confusing target function in Thread
Misunderstanding args format
5. You want to send an email asynchronously in Flask but also log the email sending status after it finishes. Which approach correctly combines async sending with logging?
hard
A. Use a thread with app context to send email, then log inside the same thread after sending
B. Send email synchronously, then start a thread to log status
C. Start two separate threads: one for sending email, one for logging, without app context
D. Send email asynchronously but log status immediately after starting the thread
Solution
Step 1: Understand async email sending with app context
Sending email in a thread requires app.app_context() to access Flask features safely.
Step 2: Combine logging after sending in same thread
Logging after sending inside the same thread ensures the status reflects actual completion.
Step 3: Evaluate other options
Logging before or in separate threads without context risks incorrect or missing info.
Final Answer:
Use a thread with app context to send email, then log inside the same thread after sending -> Option A
Quick Check:
Send and log in same app-context thread [OK]
Hint: Log after sending inside same app-context thread [OK]
Common Mistakes:
Logging before email is sent
Starting logging thread without app context
Separating send and log in different threads
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.