rameshsharma

rameshsharma

I am using Task.async to move a task in background. It is working fine in my local.
But when the code is deployed to azure environment it is not working.
Is there anything specifically I need to mention to make it work in environment.
Please suggest. My code below:-
‘’’
a = Task.async(fn →
verify_customer(current_user, first_pension)
end)
Task.await(a)

‘’’

Showing Posts 1 to 7

rameshsharma

rameshsharma OP

Any suggestions, please.

Nicd

Nicd

We need more information, just “not working” doesn’t tell us what might be wrong. Is there a crash? Are ther error logs? How did you build and deploy the code to Azure?

Note that the example you provided doesn’t make much sense, as it’s nearly the same as just running verify_customer(current_user, first_pension) in the original process. What are you aiming to accomplish with this task?

GunnarPDX

GunnarPDX

Have you tried running it without Task.async/await in prod? It’s really hard to help without error logs, the issue could be caused by a number of things unrelated to Task.async such as missing .env variables.

rameshsharma

rameshsharma OP

Yes, looks like you are correct, though in my local it works fine but I am getting some exceptions in logs due to fallback controller. Not sure if that could be the cause of the failure in azure environment.
I am getting such error in logs:-

[error] #PID<0.3298.0> running MyFutureNowWeb.Endpoint (connection #PID<0.3297.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: POST /api_v2/pension/create
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyFutureNowWeb.FallbackController.call/2
        (my_future_now 4.0.0) lib/my_future_now_web/controllers/fallback_controller.ex:8: MyFutureNowWeb.FallbackController.call(%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{user_signed_in?: true}, before_send: [#Function<0.28762384/1 in Plug.CSRFProtection.call/2>, #Function<2.77894870/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.32542428/1 in Plug.Session.before_send/2>, #Function<0.66442134/1 in Plug.Telemetry.call/2>, #Function<0.92375621/1 in Phoenix.LiveReloader.before_send_inject_reloader/2>], body_params: %{"employee_pension" => %{"creation_journey_type" => "employer", "current_employment" => "false", "end_year" => "2010", "pension_provider_id" => "", "proposed_employer_name" => "ABC Limited", "proposed_policy_number" => "", "start_year" => "2007"}}, cookies: %{}, halted: false, host: "localhost", method: "POST", owner: #PID<0.3298.0>, params: %{"employee_pension" => %{"creation_journey_type" => "employer", "current_employment" => "false", "end_year" => "2010", "pension_provider_id" => "", "proposed_employer_name" => "ABC Limited", "proposed_policy_number" => "", "start_year" => "2007"}}, path_info: ["api_v2", "pension", "create"], path_params: %{}, port: 4000, private: %{MyFutureNowWeb.Router => {[], %{Bamboo.SentEmailViewerPlug => ["sent_emails"]}}, :phoenix_action => :create, :phoenix_controller => MyFutureNowWeb.APIV2.PensionController, :phoenix_endpoint => MyFutureNowWeb.Endpoint, :phoenix_flash => %{}, :phoenix_format => "json", :phoenix_layout => {MyFutureNowWeb.LayoutView, :app}, :phoenix_router => MyFutureNowWeb.Router, :phoenix_view => MyFutureNowWeb.APIV2.PensionView, :plug_session => %{}, :plug_session_fetch => :done, :plug_session_info => :ignore}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{}, req_headers: [{"accept", "*/*"}, {"accept-encoding", "gzip, deflate, br"}, {"accept-language", "en-US,en;q=0.9"}, {"authorization", "Bearer SFMyNTY.g3QAAAACZAAEZGF0YW0AAAAkN2VhZjM1NmUtNTE0MS00ZTJiLTkwZDctMTRkNzgwYjViZTJlZAAGc2lnbmVkbgYADKLsbXQB.-yVqBqUSsRJtflbU-rit8j205c3Hb1fwnH8ysNhKlxs"}, {"cache-control", "no-cache"}, {"connection", "keep-alive"}, {"content-length", "321"}, {"content-type", "application/json"}, {"host", "localhost:4000"}, {"origin", "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop"}, {"postman-token", "d4922bac-7f43-4b65-2d7e-fb0bcc137c92"}, {"sec-fetch-dest", "empty"}, {"sec-fetch-mode", "cors"}, {"sec-fetch-site", "none"}, {"user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"}], request_path: "/api_v2/pension/create", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "FjLSWGVBjfYwu7kAAOxx"}], scheme: :http, script_name: [], secret_key_base: :..., state: :unset, status: nil}, {:ok, %MyFutureNow.Task{__meta__: #Ecto.Schema.Metadata<:loaded, "tasks">, admin_assignee: #Ecto.Association.NotLoaded<association :admin_assignee is not loaded>, admin_assignee_id: nil, admin_author: #Ecto.Association.NotLoaded<association :admin_author is not loaded>, admin_author_id: nil, body: nil, completed: false, completed_at: nil, completion_pension_status: "verify_customer_details", customer_pension: #Ecto.Association.NotLoaded<association :customer_pension is not loaded>, customer_pension_id: 844, due_date: ~D[2020-09-09], id: 457, inserted_at: ~N[2020-09-08 13:35:00.876097], priority: 1, snooze_count: 0, subject: "LexisNexis IDU FAIL, issue email to customer, set pensions to On Hold", updated_at: ~N[2020-09-08 13:35:00.876097], user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: 521, uuid: "7bb33496-6690-4780-955a-3852d0d49938"}})

kokolegorille

kokolegorille

Please note You are not using the right code fence to mark code… I updated your last post to show the difference. It should be ```

GunnarPDX

GunnarPDX

That error message is showing that your fallback controller cant match whats getting returned, which isn’t really the real error. Could you post the full function with async-await in it?

rameshsharma

rameshsharma OP

Issue is resolved…The problem was with the fallback controller. Thanks all.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews